2024-09-30 20:27:32 发布
网友
import csv with open ('database1.csv', 'a', newline='') as csvfile: linetowrite = username + "," + password + "," + dob + "," +\ favartist + "," + favgenre csvfile.write(linetowrite) csvfile.close()
这是我的代码,所有的输入都可以,但似乎有什么问题,你能帮我吗
将csvfile.write(linetowrite)更改为csvfile.write(linetowrite + "\n")。这将添加换行符
csvfile.write(linetowrite)
csvfile.write(linetowrite + "\n")
您正在导入csv模块,但从未实际使用它。为此,您需要创建如下^{}:
csv
import csv with open('database1.csv', 'w', newline='') as csvfile: csvfilewriter = csv.writer(csvfile) csvfilewriter.writerow([username, password, dob, favartist, favgenre])
将
csvfile.write(linetowrite)
更改为csvfile.write(linetowrite + "\n")
。这将添加换行符您正在导入} :
csv
模块,但从未实际使用它。为此,您需要创建如下^{相关问题 更多 >
编程相关推荐