#!/usr/local/bin/python
# Variable scope
first = 1
def one():
"Double a global variable, return it + 3."
global first
first *= 2
result = first+3
return result
print one.__doc__
print one()
print one()
print one()
print "first now has the value",first
print "result has the value",result
2008年1月24日 星期四
Python local variable and global variable
訂閱:
張貼留言 (Atom)
沒有留言:
張貼留言