[英]Python reading CSV file using URL giving error
I am trying to read a CSV file using the requests library but I am having issues. 我正在尝试使用请求库读取CSV文件,但是出现问题。
import requests
import csv
url = 'https://storage.googleapis.com/sentiment-analysis-dataset/training_data.csv'
r = requests.get(url)
text = r.iter_lines()
reader = csv.reader(text, delimiter=',')
I then tried 然后我尝试了
for row in reader:
print(row)
but it gave me this error: 但这给了我这个错误:
Error: iterator should return strings, not bytes (did you open the file in text mode?)
How should I fix this? 我该如何解决?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.