【发布时间】:2017-07-27 13:55:43
【问题描述】:
我从 youtube 上的 newboston 系列学习 python。这是来自教程 24 从 Web 下载文件。我写了和视频一样的程序:
from urllib import request
goog_url = 'https://docs.google.com/spreadsheet/ccc?
key=0At2sqNEgxTf3dEt5SXBTemZZM1gzQy1vLVFNRnludHc&output=csv'
def download_stock_data(csv_url):
response = request.urlopen(csv_url)
csv = response.read()
csv_str = str(csv)
lines = csv_str.split("\\n")
dest_url = r'goog.csv'
fx = open(dest_url, "w")
for line in lines:
fx.wirte(line + "\n")
fx.close()
download_stock_data(goog_url)
但我得到了这些错误:
Traceback (most recent call last):line 18, in <module>
download_stock_data(goog_url)
line 14, in download_stock_data
fx.wirte(line + "\n")
AttributeError: '_io.TextIOWrapper' object has no attribute 'wirte'
非常感谢任何帮助。
【问题讨论】: