Python 中汉字注释问题,各位大侠帮忙看下

wohu007 2014-04-19 03:59:13
我在Eclipse中将文件编码方式设置成UTF-8 工程编码方式也设置成UTF-8 为什么还是不能编译通过呢 ?
...全文
147 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
iasky 2014-04-21
  • 打赏
  • 举报
回复
看看你代码的前面声明了coding了么? 还有错误信息是什么?
jeky_zhang2013 2014-04-20
  • 打赏
  • 举报
回复
把代码头贴出来看下
码无边 2014-04-20
  • 打赏
  • 举报
回复
你是怎么注释?注释的时候用#
angel_su 2014-04-19
  • 打赏
  • 举报
回复
脚本开头声明编码... 2.1.4. Encoding declarations If a comment in the first or second line of the Python script matches the regular expression coding[=:]\s*([-\w.]+), this comment is processed as an encoding declaration; the first group of this expression names the encoding of the source code file. The recommended forms of this expression are # -*- coding: <encoding-name> -*- which is recognized also by GNU Emacs, and # vim:fileencoding=<encoding-name> which is recognized by Bram Moolenaar’s VIM. If no encoding declaration is found, the default encoding is UTF-8. In addition, if the first bytes of the file are the UTF-8 byte-order mark (b'\xef\xbb\xbf'), the declared file encoding is UTF-8 (this is supported, among others, by Microsoft’s notepad). If an encoding is declared, the encoding name must be recognized by Python. The encoding is used for all lexical analysis, including string literals, comments and identifiers. The encoding declaration must appear on a line of its own.

37,722

社区成员

发帖
与我相关
我的任务
社区描述
JavaScript,VBScript,AngleScript,ActionScript,Shell,Perl,Ruby,Lua,Tcl,Scala,MaxScript 等脚本语言交流。
社区管理员
  • 脚本语言(Perl/Python)社区
  • IT.BOB
加入社区
  • 近7日
  • 近30日
  • 至今

试试用AI创作助手写篇文章吧