2017-07-27 194 views
-1

我在youtube上從newboston系列學習python。這來自教程24從Web下載文件。我已經寫在同一個程序上的視頻:Python屬性錯誤:'_io.TextIOWrapper'對象沒有屬性'wirte'

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

任何幫助是極大的讚賞。

回答

0

這條消息對我來說非常明確。庫模塊正在盡最大努力告訴您,函數不叫wirte(),而是write()。只是,它不能猜測你的意思是write()

相關問題