Python AttributeError:' _io.TextIOWrapper'对象没有属性' wirte'

时间:2017-07-27 13:55:43

标签: python youtube

我正在使用youtube上的newsboston系列学习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'

This is the video link

非常感谢任何帮助。

1 个答案:

答案 0 :(得分:1)

该消息对我来说非常明确。库模块正在尽力告诉您该函数不是wirte()而是write()。只是,它无法猜测你的意思是write()