python插入mysql变量问题 20
这是我写的:importtimeimportpymysqla=0.001whileTrue:#print(a)a=a+0.001print(a)db=pymysql.co...
这是我写的:
import time
import pymysql
a = 0.001
while True:
#print(a)
a= a+0.001
print(a)
db = pymysql.connect("localhost","root","toor","center")
cursor = db.cursor()
sql = "insert into ttemp(temp)"+"values('+a+')"
try:
cursor.execute(sql)
db.commit()
except:
db.rollback()
db.close()
time.sleep(1)
但是不行。。。。。 展开
import time
import pymysql
a = 0.001
while True:
#print(a)
a= a+0.001
print(a)
db = pymysql.connect("localhost","root","toor","center")
cursor = db.cursor()
sql = "insert into ttemp(temp)"+"values('+a+')"
try:
cursor.execute(sql)
db.commit()
except:
db.rollback()
db.close()
time.sleep(1)
但是不行。。。。。 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询