2011-01-10 153 views
1

我在學習,所以對我來說很容易。Python值問題:SyntaxError:無效的語法

我在做什麼錯在這裏:

#!/usr/bin/python3.1 

import urllib.request 

page = urllib.request.urlopen ("http://au.finance.yahoo.com/q?s=AUDUSD=X") 
text = page.read().decode("utf8") 

where = text.find('Last Trade:</th><td class="yfnc_tabledata1"><big><b><span id="yfs_l10_audusd=x">') 

start_of_us_price = where + 80 
end_of_us_price = start_of_us_price + 6 

us_price = text[start_of_us_price:end_of_us_price] 

where = text.find('Trade Time:</th><td class="yfnc_tabledata1"><span id="yfs_t10_audusd=x">') 

start_of_trade_time = where + 72 
end_of_trade_time = start_of_trade_time + 11 

trade_time = text[start_of_trade_time:end_of_trade_time] 

print ('The price is $ 'us_price' as of 'trade_time'") 
+2

究竟是什麼錯誤? 你在最後一行有一個問題 - print 我認爲你的意思是:print「價格是$」,us_price,「as of」,trade_time – RoeeK

回答

4

最後一行應該是:

print ('The price is $ ', us_price, ' as of ', trade_time) 

認爲這是更好地理解它:

>>> x = 3 
>>> print('The value of x is:', 3, 'Yes!') 
The value of x is: 3 Yes! 
+0

AH!很近。謝謝! – Switchkick

相關問題