2008年01月16日 星期三 10:01
ÎÒÏëÎÊһϣ¬ÕâÁ½¸öº¯ÊýµÄµÄ 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 -------------- 下一部分 -------------- Ò»¸öHTML¸½¼þ±»ÒƳý... URL: http://python.cn/pipermail/python-chinese/attachments/20080116/91210a04/attachment-0001.html
2008年01月16日 星期三 12:15
Ò»¸öÐ޸ı¾µØ±äÁ¿Ò»¸öÐÞ¸ÄÈ«¾Ö±äÁ¿ß¡£ ÔÚ08-1-16£¬bill.wu <bill.wws在gmail.com> дµÀ£º > > ÎÒÏëÎÊһϣ¬ÕâÁ½¸öº¯ÊýµÄµÄ 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 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/20080116/121fb7f5/attachment.html
Zeuux © 2024
京ICP备05028076号