fp=open('C:\\Users\\Administrator\\Desktop\\python\\text.txt','a')
person=fp.write('name,sex\n攀攀,男')
fp.close()
importcsv
fp=open('C:\\Users\\Administrator\\Desktop\\python\\text.txt','r')
contents=fp.read()
a=contents.split('\n')
b=a[0].split(',')
c=a[1].split(',')
print(b,type(b))
fp=open('C:\\Users\\Administrator\\Desktop\\python\\text.csv','a',newline='')
writer=csv.writer(fp)
writer.writerow(b)
writer.writerow(c)
fp.close()