2011-01-10 4 views
1

배우고 있습니다.파이썬 값 문제 : 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 "The price is $", us_price, "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

관련 문제