我写了一个程序来获取Mega Doge Coin的价值。
但是当我运行它时,出现了以下错误:
import time
import urllib2
from datetime import datetime
def get_HTML():
response = urllib.request.urlopen('http://www.dogepay.com')
html = response.read()
return html
def get_Value(rawHTML):
index = rawHTML.find(“CCFF00”)
while(rawHTML[index] != “$”):
index = index + 1
index = index + 1
value = “”
while(rawHTML[index].isdigit() or rawHTML[index] == ‘.’):
value = value + rawHML[index]
index = index + 1
return float(value)
def get_DateTime():
now = datetime.now()
return '%s/%s/%s %s:%s:%s' % (now.month, now.day, now.year, now.hour,
now.minute, now.second)
def print_Output(DogeCoinValue, TimeDate):
print timeDate + “ $“ + str(dogeCoinValue)
while(True):
rawHTML = get_HTML()
dogeCoinValue = get_Value(rawHTML)
timeDate = get_DateTime()
print_Output(dogeCoinValue, timeDate)
time.sleep(5)
但是当我运行它时,出现了以下错误:
File "MegaDogeCoinTicker.py", line 11
SyntaxError: Non-ASCII character '\xe2' in file MegaDogeCoinTicker.py on line
11, but no encoding declared; see http://www.python.org/peps/pep-0263.html
for details
我需要做什么来修复它?当我在我的树莓派上运行它时,它是有效的,但我似乎无法在我的笔记本电脑上运行它。我的笔记本电脑正在运行Python 2.7.5。
“
改成了"
,把所有的‘
改成了'
,然后得到了以下错误信息:Traceback (most recent call last): File "MegaDogeCoinTicker.py", line 29, in
rawHTML = get_HTML()
File "MegaDogeCoinTicker.py", line 6, in get_HTML
response = urllib.request.urlopen('http://www.dogepay.com')
NameError: global name 'urllib' is not defined
- AceFuzion