我拥有的 Python 代码如下所示
f = open('data.tsv', 'r')
for line in f:
a = line.split("\t")
e_id = a[1]
name = a[2]
start = a[3]
end = a[4]
loc = a[5]
tags = a[6]
url = a[7]
cur = con.cursor(mdb.cursors.DictCursor)
cur.execute("INSERT INTO data_table VALUES (" + e_id + "," + name + "," + start + "," + end + "," + loc + "," + tags + "," + url + ");")
“loc”数据块中经常有一个逗号,因为它的很多格式是“City, State”,所以 MySQL 将它解释为一个值。我不能直接注释掉逗号,因为它们被存储为变量。有没有解决的办法?