2006年03月14日 星期二 16:42
Hi, 如果python用缩进来控制程序结构,那为什么在if等一些语句最后还需要冒号呢?
2006年03月14日 星期二 16:45
On 3/14/06, Julius F. Huang <fozzold at gmail.com> wrote: > Hi, > > 如果python用缩进来控制程序结构,那为什么在if等一些语句最后还需要冒号呢? > 不用冒号怎么知道一行结束呢? -- I like python! My Blog: http://www.donews.net/limodou NewEdit Maillist: http://groups.google.com/group/NewEdit
2006年03月14日 星期二 16:49
看后面的语句的缩进来确定呀 On 3/14/06, limodou <limodou at gmail.com> wrote: > On 3/14/06, Julius F. Huang <fozzold at gmail.com> wrote: > > Hi, > > > > 如果python用缩进来控制程序结构,那为什么在if等一些语句最后还需要冒号呢? > > > > 不用冒号怎么知道一行结束呢? > > > -- > I like python! > My Blog: http://www.donews.net/limodou > NewEdit Maillist: http://groups.google.com/group/NewEdit > > _______________________________________________ > python-chinese > Post: send python-chinese at lists.python.cn > Subscribe: send subscribe to python-chinese-request at lists.python.cn > Unsubscribe: send unsubscribe to python-chinese-request at lists.python.cn > Detail Info: http://python.cn/mailman/listinfo/python-chinese > >
2006年03月14日 星期二 17:05
with colon you can write the following:
if 1== \
1:
print 'ok'
----- Original Message -----
From: "Julius F. Huang" <fozzold at gmail.com>
To: <python-chinese at lists.python.cn>
Sent: Tuesday, March 14, 2006 4:49 PM
Subject: Re: [python-chinese] 缩进和冒号
> 看后面的语句的缩进来确定呀
>
>
> On 3/14/06, limodou <limodou at gmail.com> wrote:
>> On 3/14/06, Julius F. Huang <fozzold at gmail.com> wrote:
>> > Hi,
>> >
>> > 如果python用缩进来控制程序结构,那为什么在if等一些语句最后还需要冒号呢?
>> >
>>
>> 不用冒号怎么知道一行结束呢?
>>
>>
>> --
>> I like python!
>> My Blog: http://www.donews.net/limodou
>> NewEdit Maillist: http://groups.google.com/group/NewEdit
>>
>> _______________________________________________
>> python-chinese
>> Post: send python-chinese at lists.python.cn
>> Subscribe: send subscribe to python-chinese-request at lists.python.cn
>> Unsubscribe: send unsubscribe to python-chinese-request at lists.python.cn
>> Detail Info: http://python.cn/mailman/listinfo/python-chinese
>>
>>
>
--------------------------------------------------------------------------------
> _______________________________________________
> python-chinese
> Post: send python-chinese at lists.python.cn
> Subscribe: send subscribe to python-chinese-request at lists.python.cn
> Unsubscribe: send unsubscribe to python-chinese-request at lists.python.cn
> Detail Info: http://python.cn/mailman/listinfo/python-chinese
2006年03月14日 星期二 17:08
On 3/14/06, Julius F. Huang <fozzold at gmail.com> wrote: > 看后面的语句的缩进来确定呀 > python允许一行写不下写在下一行,那怎么办? -- I like python! My Blog: http://www.donews.net/limodou NewEdit Maillist: http://groups.google.com/group/NewEdit
2006年03月14日 星期二 17:42
是不是缩进只是python为了避免太多分隔符,比如分号,括号等,采取的一种手段而已
我看python的文档里写着:
if stmt ::= "if" expression ":" suite
suite ::= stmt_list NEWLINE
stmt_list ::= simple_stmt (";" simple_stmt)* [";"]
simple_stmt ::= expression_stmt
如果把程序写在一行上,就要用分号来分割了。
On 3/14/06, limodou <limodou at gmail.com> wrote:
> On 3/14/06, Julius F. Huang <fozzold at gmail.com> wrote:
> > 看后面的语句的缩进来确定呀
> >
>
> python允许一行写不下写在下一行,那怎么办?
>
> --
> I like python!
> My Blog: http://www.donews.net/limodou
> NewEdit Maillist: http://groups.google.com/group/NewEdit
>
> _______________________________________________
> python-chinese
> Post: send python-chinese at lists.python.cn
> Subscribe: send subscribe to python-chinese-request at lists.python.cn
> Unsubscribe: send unsubscribe to python-chinese-request at lists.python.cn
> Detail Info: http://python.cn/mailman/listinfo/python-chinese
>
>
2006年03月14日 星期二 18:28
缩进是为了强制用户按规范的格式书写代码。 2006/3/14, Julius F. Huang <fozzold at gmail.com>: > > 是不是缩进只是python为了避免太多分隔符,比如分号,括号等,采取的一种手段而已 > > 我看python的文档里写着: > if stmt ::= "if" expression ":" suite > suite ::= stmt_list NEWLINE > stmt_list ::= simple_stmt (";" simple_stmt)* [";"] > simple_stmt ::= expression_stmt > > 如果把程序写在一行上,就要用分号来分割了。 > > > > > On 3/14/06, limodou <limodou at gmail.com> wrote: > > On 3/14/06, Julius F. Huang <fozzold at gmail.com> wrote: > > > 看后面的语句的缩进来确定呀 > > > > > > > python允许一行写不下写在下一行,那怎么办? > > > > -- > > I like python! > > My Blog: http://www.donews.net/limodou > > NewEdit Maillist: http://groups.google.com/group/NewEdit > > > > _______________________________________________ > > python-chinese > > Post: send python-chinese at lists.python.cn > > Subscribe: send subscribe to python-chinese-request at lists.python.cn > > Unsubscribe: send unsubscribe to python-chinese-request at lists.python.cn > > Detail Info: http://python.cn/mailman/listinfo/python-chinese > > > > > > _______________________________________________ > python-chinese > Post: send python-chinese at lists.python.cn > Subscribe: send subscribe to python-chinese-request at lists.python.cn > Unsubscribe: send unsubscribe to python-chinese-request at lists.python.cn > Detail Info: http://python.cn/mailman/listinfo/python-chinese > > -- 欢迎访问: http://blog.csdn.net/ccat 刘鑫 March.Liu -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.exoweb.net/pipermail/python-chinese/attachments/20060314/874bb977/attachment.html
2006年03月14日 星期二 20:22
ß@ÑeÓнâ᣺ http://www.python.org/doc/faq/general/#why-are-colons-required-for-the-if-while-def-class-statements ðÌÒ²²»Êǽ^¦±ØÒª£¬²»ß^ pythoneer ϲg¡£ On 3/14/06, limodou <limodou at gmail.com> wrote: > > On 3/14/06, Julius F. Huang <fozzold at gmail.com> wrote: > > Hi, > > > > Èç¹ûpythonÓÃËõ½øÀ´¿ØÖƳÌÐò½á¹¹£¬ÄÇΪʲôÔÚifµÈһЩÓï¾ä×îºó»¹ÐèҪðºÅÄØ£¿ > > > > ²»ÓÃðºÅÔõô֪µÀÒ»ÐнáÊøÄØ£¿ > > > -- > I like python! > My Blog: http://www.donews.net/limodou > NewEdit Maillist: http://groups.google.com/group/NewEdit > > _______________________________________________ > python-chinese > Post: send python-chinese at lists.python.cn > Subscribe: send subscribe to python-chinese-request at lists.python.cn > Unsubscribe: send unsubscribe to python-chinese-request at lists.python.cn > Detail Info: http://python.cn/mailman/listinfo/python-chinese > > -- with regards, Yung-Yu Chen Gmail/Gtalk: yungyuc at gmail.com Email (permanent): yyc at seety.org http://yungyuc.net/ -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.exoweb.net/pipermail/python-chinese/attachments/20060314/416901c5/attachment.html
2006年03月15日 星期三 08:41
可以接受的解释,:P On 3/14/06, Yung-Yu Chen <yyc at seety.org> wrote: > 這裡有解釋: > http://www.python.org/doc/faq/general/#why-are-colons-required-for-the-if-while-def-class-statements > 冒號也不是絕對必要,不過 pythoneer 喜歡。 > > On 3/14/06, limodou <limodou at gmail.com> wrote: > > > > On 3/14/06, Julius F. Huang <fozzold at gmail.com> wrote: > > > Hi, > > > > > > 如果python用缩进来控制程序结构,那为什么在if等一些语句最后还需要冒号呢? > > > > > > > 不用冒号怎么知道一行结束呢? > > > > > > -- > > I like python! > > My Blog: http://www.donews.net/limodou > > NewEdit Maillist: http://groups.google.com/group/NewEdit > > > > _______________________________________________ > > python-chinese > > Post: send python-chinese at lists.python.cn > > Subscribe: send subscribe to > python-chinese-request at lists.python.cn > > Unsubscribe: send unsubscribe to > python-chinese-request at lists.python.cn > > Detail Info: > http://python.cn/mailman/listinfo/python-chinese > > > > > > > > -- > with regards, > Yung-Yu Chen > > Gmail/Gtalk: yungyuc at gmail.com > Email (permanent): yyc at seety.org > http://yungyuc.net/ > _______________________________________________ > python-chinese > Post: send python-chinese at lists.python.cn > Subscribe: send subscribe to > python-chinese-request at lists.python.cn > Unsubscribe: send unsubscribe to > python-chinese-request at lists.python.cn > Detail Info: > http://python.cn/mailman/listinfo/python-chinese > >
Zeuux © 2025
京ICP备05028076号