【问题标题】:Python AttributeError: '_io.TextIOWrapper' object has no attribute 'wirte'Python AttributeError: '_io.TextIOWrapper' 对象没有属性 'write'
【发布时间】: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'

This is the video link

非常感谢任何帮助。

【问题讨论】:

    标签: python youtube


    【解决方案1】:

    那条消息对我来说看起来很明确。库模块正在尽最大努力告诉您该函数不是称为wirte() 而是write()。只是,它猜不出你的意思是write()

    【讨论】:

      猜你喜欢
      • 2015-08-16
      • 2021-05-31
      • 2014-01-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-07-06
      • 1970-01-01
      相关资源
      最近更新 更多