python3编译器运行无措,终端运行即出错,小白求教大神
代码为:
import json
import pymysql
def get_data():
with open('/var/www/html/aqi1.json', 'r') as f:
pm_text = json.load(f) # 解析每一行数据
return pm_text
def data_insert(pm_text):
db = pymysql.connect("localhost", "root", "trafficlab507-1", "sensordb ")
cursor = db.cursor()
value_pm = ((pm_text['aqi1']['pm10'], pm_text['aqi1']['pm25'], pm_text['aqi1']['time']))
insert_pm = "insert into pmdb(pm10,pm25,recordtime) values (%s,%s,%s)"
cursor = db.cursor()
cursor.execute(insert_pm, value_pm)
db.commit()
cursor.close()
报错内容为:
./qq.py:行3: 未预期的符号 `(' 附近有语法错误
./qq.py:行3: `def get_data():'