Re: Rs: help, thanks very much.
Lich_Ray <[email protected]>
| Newsgroups | gmane.comp.python.chinese |
|---|---|
| Message-ID | <[email protected]> |
一个修改本地变量一个修改全局变量呗。 在08-1-16,bill.wu <[email protected]> 写道: > > 我想问一下,这两个函数的的 def func(x)和func() 一个带X一个不带X,请问是什么区别?为什么? > > > (1) > > def func*(x)*: > print 'x is', x > x = 2 > print 'Changed local x to', x > > x = 50 > func*(x)* > print 'x is still', x > (2) > > def func*()*: > global x > > print 'x is', x > x = 2 > print 'Changed local x to', x > > x = 50 > func*()* > print 'Value of x is', x > ____________________________________________________________________ > ____________________________________________ > *DreamMail* - 电子邮件新体验 www.dreammail.org > > _______________________________________________ > python-chinese > Post: send [email protected] > Subscribe: send subscribe to [email protected] > Unsubscribe: send unsubscribe to [email protected] > 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 [email protected] Subscribe: send subscribe to [email protected] Unsubscribe: send unsubscribe to [email protected] Detail Info: http://python.cn/mailman/listinfo/python-chinese