SyntaxError: Non-ASCII character '\xe5' in file D:/pcode/xx.py on line 21, but no encoding declared
2014-05-15 18:16
811 查看
from selenium import webdriver from datetime import * import time starttime = datetime.now() print ("start time:%s" %starttime) dr = webdriver.Firefox() url = "http://www.sohu.com" print('now access %s' %url) dr.get(url) #time.sleep(3) endtime = datetime.now() print ("end time:%s"%endtime) print("u共花费毫秒:",endtime-starttime).microseconds dr.quit()
报错:SyntaxError: Non-ASCII character '\xe5' in file D:/pcode/xx.py on line 21, but no encoding declared
修改后成功代码:
#coding=utf-8 from selenium import webdriver from datetime import * import time starttime = datetime.now() print ("start time:%s" %starttime) dr = webdriver.Firefox() url = "http://www.sohu.com" print('now access %s' %url) dr.get(url) #time.sleep(3) endtime = datetime.now() print ("end time:%s"%endtime) info = u'共花费时间:(秒)' print(info.encode('utf-8')+str((endtime-starttime).seconds)) dr.quit()
相关文章推荐
- SyntaxError: Non-ASCII character '\xe5' in file index.py on line 6, but no encoding declared; see http://python.org/dev/peps/pep-0263/ for details
- SyntaxError: Non-ASCII character '\xe5' in file a.py on line 9, but no encoding declared; see http://www.python.org/peps/pep-0263.html for details
- 【python问题系列--1】SyntaxError:Non-ASCII character '\xe5' in file kNN.py on line 2, but no encoding declared;
- SyntaxError: Non-UTF-8 code starting with '\xc5' in file t.py on line 3,but no encoding declared;see http://python.org/dev/peps/pep-0263/ for details
- Python: SyntaxError: Non-ASCII character '\xa3' in file main.py on line 3, but no encoding declared
- python - 中文打印报错SyntaxError: Non-ASCII character '\xe4' in file test.py on line 3, but no encoding declared。
- SyntaxError: Non-ASCII character '\xe8' in file model.py on line 300, but no encoding declared; 报错
- [已解决]关于python无法显示中文的问题:SyntaxError: Non-ASCII character '\xe4' in file test.py on line 3, but no encoding declared。
- SyntaxError: Non-ASCII character '\xe4' in file test.py on line 3, but no encoding declared。
- 关于python无法显示中文的问题:SyntaxError: Non-ASCII character '\xe4' in file test.py on line 3, but no encoding
- SyntaxError: Non-ASCII character '***' in file *** on line **,but no encoding declared;
- python问题Non-ASCII character '\xe5' in file Apriori.py on line 1, but no encoding declared 解决办法
- python问题Non-ASCII character '\xe5' in file Apriori.py on line 1, but no encoding declared 解决办法
- 关于python无法显示中文的问题:SyntaxError: Non-ASCII character '\xe4' in file test.py on line 3, but no encoding
- Non-ASCII character '\xe8' in file xxx.py on line 8, but no encoding declared
- 关于python无法显示中文的问题:SyntaxError: Non-ASCII character '\xe4' in file test.py on line 3, but no encoding
- python问题Non-ASCII character '\xe5' in file Apriori.py on line 1, but no encoding declared 解决办法
- Non-ASCII character '\xe8' in file xxx.py on line 8, but no encoding declared
- [已解决]关于python无法显示中文的问题:SyntaxError: Non-ASCII character '\xe4' in file test.py on line 3, but no enc
- python出现SyntaxError: Non-ASCII character '\xe6' in file 打印日期.py on line 1, but no encoding declared;