[英]Read Write mode Python CSV file
工作的一个项目,但我想,当我打开CSV文件的读写模式。 可悲的是,它给了我一个错误。 这是代码:
import csv
with open("historicalData/ACAD.csv", "rw") as csv_file:
csv_reader = csv.reader(csv_file, delimiter=',')
for lines in csv_reader:
print(lines[0])
我得到的错误:
Traceback (most recent call last):
File "c:/Users/sande/Desktop/Vihaan/ThirdPartySoftware/Python/VisualStudiosCode/DadWork/test.py", line 3, in <module>
with open("historicalData/ACAD.csv", "ra") as csv_file:
ValueError: must have exactly one of create/read/write/append mode
任何人都可以帮助实现这一目标吗?
使用r+
或a+
或w+
而不是rw
因为 python 无法识别它
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.