def daoru():
file = filedialog.askopenfilename() # 选择文件文件路径
with open(file, encoding='utf-8') as file: # 读取文件内容
content = file.read()
data1 = content.split('\n') # 用换行符分割数据
for i in range(len(data1)):
item = data1[i].split('----') #
sql = 'insert into cd_phone (`phone`,`com`,`ctime`) values ("%s","%s",%s)' % (
item[1], item[0], int(time.time()))
insert(sql) # 添加数据到数据库
查看insert使用方法