Python论坛  - 讨论区

标题:[python-chinese] 缩进和冒号

2006年03月14日 星期二 16:42

Julius F. Huang fozzold at gmail.com
Tue Mar 14 16:42:04 HKT 2006

Hi,

如果python用缩进来控制程序结构,那为什么在if等一些语句最后还需要冒号呢?

[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

2006年03月14日 星期二 16:45

limodou limodou at gmail.com
Tue Mar 14 16:45:36 HKT 2006

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

[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

2006年03月14日 星期二 16:49

Julius F. Huang fozzold at gmail.com
Tue Mar 14 16:49:37 HKT 2006

看后面的语句的缩进来确定呀


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
>
>

[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

2006年03月14日 星期二 17:05

Slowness Chen chenzh at bhh.com.cn
Tue Mar 14 17:05:48 HKT 2006

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 


[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

2006年03月14日 星期二 17:08

limodou limodou at gmail.com
Tue Mar 14 17:08:46 HKT 2006

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

[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

2006年03月14日 星期二 17:42

Julius F. Huang fozzold at gmail.com
Tue Mar 14 17:42:12 HKT 2006

是不是缩进只是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
>
>

[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

2006年03月14日 星期二 18:28

刘鑫 march.liu at gmail.com
Tue Mar 14 18:28:00 HKT 2006

缩进是为了强制用户按规范的格式书写代码。

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

[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

2006年03月14日 星期二 20:22

Yung-Yu Chen yyc at seety.org
Tue Mar 14 20:22:27 HKT 2006

ß@Ñ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

[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

2006年03月15日 星期三 08:41

Julius F. Huang fozzold at gmail.com
Wed Mar 15 08:41:08 HKT 2006

可以接受的解释,: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
>
>

[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

如下红色区域有误,请重新填写。

    你的回复:

    请 登录 后回复。还没有在Zeuux哲思注册吗?现在 注册 !

    Zeuux © 2025

    京ICP备05028076号