python注释问题

9 views
Skip to first unread message

yangyi

unread,
Nov 18, 2008, 9:02:10 AM11/18/08
to pyth...@googlegroups.com
在python中大家是如何使用多行注释和中文注释的。比如C语言中的
/*
int a
int b
*/

还有注释中用中文就报错,大家遇到过这种情况吗?

Jin Xu

unread,
Nov 18, 2008, 9:04:03 AM11/18/08
to pyth...@googlegroups.com
中文注释报错应该是编码问题

张沈鹏

unread,
Nov 18, 2008, 9:14:18 AM11/18/08
to pyth...@googlegroups.com
2008/11/18 Jin Xu <xuji...@gmail.com>:
> 中文注释报错应该是编码问题

1,开头
#coding:utf-8

2.多行
"""
xxx
xxx
"""

vi

guangge77

unread,
Nov 18, 2008, 9:48:47 AM11/18/08
to python-cn
编码错详细一点的解决方式就是:在你的文件的第一行如下写:
# -*- coding: utf-8 -*-
第二行如果有必要,写:
#!/usr/local/bin/python
其中utf-8可以是'gb2312'或其他,推荐用utf-8,py3.0对utf-8非常友好.
 
2008-11-18

光哥, pythoner, wower,驴友  

发件人: Jin Xu
发送时间: 2008-11-18  22:04:33
收件人: python-cn
抄送:
主题: [CPyUG:71706]_Re:_python注释问题
中文注释报错应该是编码问题

guangge77

unread,
Nov 18, 2008, 9:49:42 AM11/18/08
to python-cn
哦 忘了说,你那个注释报错,为什么不是注释的问题,你在注释外写个中文就会发现问题了.

马踏飞燕

unread,
Nov 18, 2008, 8:47:00 PM11/18/08
to pyth...@googlegroups.com
多行中文注释可以直接指定unicode。

u"""
中俄文
中俄文
中俄文
中俄文
"""

这样就不会出错了。

2008/11/18 yangyi <lesx...@gmail.com>:

--
免费手机铃声电子书下载,在线观看!
尽在 http://www.honeyday.org

Zoom.Quiet

unread,
Nov 18, 2008, 8:49:43 PM11/18/08
to pyth...@googlegroups.com
2008/11/19 马踏飞燕 <honey...@gmail.com>:
> 多行中文注释可以直接指定unicode。
>
嗯嗯嗯! 俺一向忽略这种事儿的,原来可以这么整,
3.0 之后就没有这种问题了,,,

> u"""
> 中俄文
> 中俄文
> 中俄文
> 中俄文
> """
>
> 这样就不会出错了。
>
> 2008/11/18 yangyi <lesx...@gmail.com>:
>>
>> 在python中大家是如何使用多行注释和中文注释的。比如C语言中的
>> /*
>> int a
>> int b
>> */
>>
>> 还有注释中用中文就报错,大家遇到过这种情况吗?
>>
>>

--
http://zoomquiet.org'''
过程改进乃是催生可促生靠谱的人的组织!
PE keeps evolving organizations which promoting people be good!'''
[HR]金山软件常年招聘大量Py/C++人才!
https://groups.google.com/group/python-cn/web/ot-py-c
简历直投俺就好;-)

Zoom.Quiet

unread,
Nov 18, 2008, 8:52:53 PM11/18/08
to pyth...@googlegroups.com
2008/11/19 Zoom. Quiet <zoom....@gmail.com>:

> 2008/11/19 马踏飞燕 <honey...@gmail.com>:
>> 多行中文注释可以直接指定unicode。
>>
> 嗯嗯嗯! 俺一向忽略这种事儿的,原来可以这么整,
> 3.0 之后就没有这种问题了,,,
>

PS:
收录!
http://wiki.woodpecker.org.cn/moin/MiscItems/2008-11-19

Heroboy

unread,
Nov 18, 2008, 9:02:30 PM11/18/08
to pyth...@googlegroups.com
没看明白用unicode和不用unicode的差别。
只有运行的时候才会变成unicode啊。注释加个u是有什么特殊含义吗。

2008/11/19 Zoom. Quiet <zoom....@gmail.com>

小楼

unread,
Jan 1, 2009, 1:25:34 AM1/1/09
to python-cn`CPyUG`华蟒用户组
idle 3.0中
#coding:utf-8
#中国
print('a')

alt+x都崩溃,别说运行了,文件也是utf8格式的,为什么啊?
受不了了,有中文就自动退出了

On 2008年11月19日, 上午9时49分, Zoom.Quiet <zoom.qu...@gmail.com> wrote:
> 2008/11/19 马踏飞燕 <honeyday...@gmail.com>:> 多行中文注释可以直接指定unicode。


>
> 嗯嗯嗯! 俺一向忽略这种事儿的,原来可以这么整,
> 3.0 之后就没有这种问题了,,,
>
>
>
>
>
> > u"""
> > 中俄文
> > 中俄文
> > 中俄文
> > 中俄文
> > """
>
> > 这样就不会出错了。
>

> > 2008/11/18 yangyi <lesxc1...@gmail.com>:


>
> >> 在python中大家是如何使用多行注释和中文注释的。比如C语言中的
> >> /*
> >> int a
> >> int b
> >> */
>
> >> 还有注释中用中文就报错,大家遇到过这种情况吗?
>

> --http://zoomquiet.org'''


> 过程改进乃是催生可促生靠谱的人的组织!
> PE keeps evolving organizations which promoting people be good!'''
> [HR]金山软件常年招聘大量Py/C++人才!https://groups.google.com/group/python-cn/web/ot-py-c

> 简历直投俺就好;-)- 隐藏被引用文字 -
>
> - 显示引用的文字 -

iamzcy_hit iamzcy_hit

unread,
Jan 1, 2009, 8:07:47 PM1/1/09
to pyth...@googlegroups.com
用ulipad吧

2009/1/1 小楼 <qdl...@163.com>

东东爸

unread,
Jan 1, 2009, 10:14:20 PM1/1/09
to pyth...@googlegroups.com
同推荐。现在用Python编程就用Ulipad做编辑器,调试也用它,很好用~~

2009/1/2 iamzcy_hit iamzcy_hit <iamz...@gmail.com>



--
Best Regards!

Ace Strong

==================================================
Nanjing University of Aeronautics and Astronautics.
College of Civil Aviation
Tao Cheng
E-mail: aces...@gmail.com ;aces...@nuaa.edu.cn
Tel: 86-025-84892273
==================================================

iamzcy_hit iamzcy_hit

unread,
Jan 2, 2009, 7:01:28 AM1/2/09
to pyth...@googlegroups.com
不知道增加缩进和减少缩进有没有快捷键?

2009/1/2 东东爸 <aces...@gmail.com>

Zoom.Quiet

unread,
Jan 2, 2009, 7:28:19 AM1/2/09
to pyth...@googlegroups.com
2009/1/2 iamzcy_hit iamzcy_hit <iamz...@gmail.com>:
> 不知道增加缩进和减少缩进有没有快捷键?
>
tab
shift+tab


--
http://zoomquiet.org
'''过程改进乃是催生可促生靠谱的人的组织!'''
金山常年招聘Py/C++人才! http://bit.ly/UoTV 简历直投俺就成;-)

Reply all
Reply to author
Forward
0 new messages