开发者

Python value problem: SyntaxError: invalid syntax

开发者 https://www.devze.com 2023-02-03 04:26 出处:网络
I\'m learning, so go easy on me. What am I doing wrong here: #!/usr/bin/python3.1 import urllib.request page = urllib.request.urlopen (\"http://au.finance.yahoo.com/q?s=AUDUSD=X\")

I'm learning, so go easy on me.

What am I doing wrong here:

#!/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'")


The last line should be:

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

Consider this to understand it better:

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

精彩评论

暂无评论...
验证码 换一张
取 消