怎样将多行数据变为数据库可查询条件,如:
8908862
8909036
8909078
8909100
8909596
处理之后:
'8908862','8909036','8909078','8909100','8909596'
path1 = r'D:\Document\DataConversion\originFile.txt'
path2 = r'D:\Document\DataConversion\middleFile.txt'
path3 = r'D:\Document\DataConversion\finalFile.txt'
file1 = open(path1,'r+')
file2 = open(path2,'r+')
content1=file1.readlines()
length=len(content1)
for a in range(0,length):
file2.write("\'")
content2=content1[a].strip('\n')
file2.write(content2)
file2.write("\',")
file1.close()
file2.close()
file2 = open(path2,'r+')
content3=file2.read()
content3=content3.strip("\,")
file3 = open(path3,'r+')
file3.write(content3)
file2.close()
file3.close()
|