【发布时间】:2014-08-14 13:44:59
【问题描述】:
string = "Deepika Padukone, Esha Gupta or Yami Gautam - Who's looks hotter and sexier? Vote! - It's ... Deepika Padukone, Esha Gupta or Yami Gautam…. Deepika Padukone, Esha Gupta or Yami Gautam ... Tag: Deepika Padukone, Esha Gupta, Kalki Koechlin, Rang De Basanti, Soha Ali Khan, Yami ... Amitabh Bachchan and Deepika Padukone to be seen in Shoojit Sircar's Piku ..."
fp = open("test.txt", "w+");
fp.write("%s" %string);
运行上述代码后,出现以下错误。
File "encode_error.py", line 1
SyntaxError: Non-ASCII character '\xe2' in file encode_error.py on line 1, but no encoding declared; see http://www.python.org/peps/pep-0263.html for details
【问题讨论】:
-
您阅读所提供的链接了吗?
-
@hd1:真的吗?在源文件中,然后使用 Python 2 运行? 不要只是将它粘贴到交互式 Python 会话中。
-
Deepika Padukone +1。
标签: python