Python论坛  - 讨论区

标题:[python-chinese] local global

2007年11月23日 星期五 16:14

Pattern Liu liufengsjtu在gmail.com
星期五 十一月 23 16:14:06 HKT 2007

ÏÂÃæÒ»¶Î³ÌÐòµÄ´íÎóÌáʾ£¬ÊDz»ÊǺÍpythonµÄ°æ±¾ÓйØϵÄØ
There is an error in your program
***name 'x' is local and global

Ô´´úÂëÈçÏÂ
#!/usr/bin/python
# Filename:func_global.py
def func(x):
    global x
    print 'x is' , x
    x=2
    print 'Changed global x to',x
x=50
func(x)
print 'Value of x is',x
-------------- 下一部分 --------------
Ò»¸öHTML¸½¼þ±»ÒƳý...
URL: http://python.cn/pipermail/python-chinese/attachments/20071123/4603f103/attachment.htm 

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

zy

2007年11月23日 星期五 17:06

Lich_Ray solo.lich在gmail.com
星期五 十一月 23 17:06:10 HKT 2007

ÄãµÄ²ÎÊýÁбíÀïÓбäÁ¿x£¬ÒѾ­ÊÇlocalÁË£¬ÈκÎÓïÑÔÔ­ÔòÉÏlocal²»¸²¸ÇÉϼ¶¡£
ÄѵÀûעÒâµ½ÕâÊÇÒ»¸öSyntaxErrorÂð£¿Òâ˼¾ÍÊÇ˵²»ÓÃÖ´ÐУ¬Ð´·¨¾ÍÊÇ´íµÄ¡£

ÔÚ07-11-23£¬Pattern Liu <liufengsjtu在gmail.com> дµÀ£º
>
> ÏÂÃæÒ»¶Î³ÌÐòµÄ´íÎóÌáʾ£¬ÊDz»ÊǺÍpythonµÄ°æ±¾ÓйØϵÄØ
> There is an error in your program
> ***name 'x' is local and global
>
> Ô´´úÂëÈçÏÂ
> #!/usr/bin/python
> # Filename:func_global.py
> def func(x):
>     global x
>     print 'x is' , x
>     x=2
>     print 'Changed global x to',x
> x=50
> func(x)
> print 'Value of x is',x
>
>
>
> _______________________________________________
> python-chinese
> Post: send python-chinese在lists.python.cn
> Subscribe: send subscribe to python-chinese-request在lists.python.cn
> Unsubscribe: send unsubscribe to  python-chinese-request在lists.python.cn
> Detail Info: http://python.cn/mailman/listinfo/python-chinese
>



-- 
Ray Stinger, nickname Lich_Ray
God is in his heaven, all's right with the world.
-------------------------------------------------
let focus = 'computing' in where:
http://lichray.javaeye.com
let focus = 'computing' in here:
http://lichray.bokeland.com
-------------- 下一部分 --------------
Ò»¸öHTML¸½¼þ±»ÒƳý...
URL: http://python.cn/pipermail/python-chinese/attachments/20071123/7f860ecd/attachment.htm 

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

2007年11月27日 星期二 01:35

Cyril.Liu terry6394在gmail.com
星期二 十一月 27 01:35:55 HKT 2007

name 'x' is local and global
È˼ÒPython²»ÊǸæËßÄãÁËÂ𣿣¡
˵ÄãxÊǾֲ¿ÓÖÊÇÈ«¾Ö£¬ÄãÖ»ÄÜÑ¡Ò»¸ö£¬²»ÄÜÁ½¸ö¶¼Òª£¬¾ßÌåÒªÄĸö¾ÍÄã×Ô¼º¿´×Å°ìÁË¡£

On Nov 23, 2007 5:06 PM, Lich_Ray <solo.lich at gmail.com> wrote:

> ÄãµÄ²ÎÊýÁбíÀïÓбäÁ¿x£¬ÒѾ­ÊÇlocalÁË£¬ÈκÎÓïÑÔÔ­ÔòÉÏlocal²»¸²¸ÇÉϼ¶¡£
> ÄѵÀûעÒâµ½ÕâÊÇÒ»¸öSyntaxErrorÂð£¿Òâ˼¾ÍÊÇ˵²»ÓÃÖ´ÐУ¬Ð´·¨¾ÍÊÇ´íµÄ¡£
>
> ÔÚ07-11-23£¬Pattern Liu <liufengsjtu at gmail.com > дµÀ£º
> >
> > ÏÂÃæÒ»¶Î ³ÌÐòµÄ´íÎóÌáʾ£¬ÊDz»ÊǺÍpythonµÄ°æ±¾ÓйØϵÄØ
> >
> > There is an error in your program
> > ***name 'x' is local and global
> >
> > Ô´´úÂëÈçÏÂ
> > #!/usr/bin/python
> > # Filename:func_global.py
> > def func(x):
> >     global x
> >     print 'x is' , x
> >     x=2
> >     print 'Changed global x to',x
> > x=50
> > func(x)
> > print 'Value of x is',x
> >
> >
> >
> > _______________________________________________
> > 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
> >
>
>
>
> --
> Ray Stinger, nickname Lich_Ray
> God is in his heaven, all's right with the world.
> -------------------------------------------------
> let focus = 'computing' in where:
> http://lichray.javaeye.com
> let focus = 'computing' in here:
> http://lichray.bokeland.com
> _______________________________________________
> 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
>



-- 
About Cyril.Liu
-----------------------------------
Cyril
ÊÇÒ»¸ö³ÌÐòÔ±,
ÏÖÔÚÊǸöÇî¹âµ°,
Ëû³£³£¸ú×Ô¼ºËµ:"Î҆ÕÒ»‚€ÓÐÀíÏë†þ΁ţ×Ð×Ð"
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://python.cn/pipermail/python-chinese/attachments/20071127/23b92495/attachment-0001.htm 

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

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

    你的回复:

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

    Zeuux © 2025

    京ICP备05028076号