开发者

Convert to a urllib.request to an integer

开发者 https://www.devze.com 2023-02-04 11:51 出处:网络
Am I able to convert the value us_price into an integer after the following: import urllib.request page = urllib.request.urlopen (\"http://au.finance.yahoo.com/q?s=AUDUSD=X\")

Am I able to convert the value us_price into an integer after the following:

import urllib.request

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

where1 = text.find('yfs_l10_audusd=x">')

start_of_u开发者_StackOverflow中文版s_price = where1 + 18
end_of_us_price = start_of_us_price + 6

us_price = text[start_of_us_price:end_of_us_price]

I have tried usp = int(us_price) to no avail


You probably should use float(us_price), but if you want int then int(float(us_price)).

0

精彩评论

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

关注公众号