Thanks for all the replys.
"Diez B. Roggisch 写道:
"
> hollowspook schrieb:
> > def aa():
> > global b
> > b=b+1
> > print b
> >
> > b=1
> > aa()
> >
> > The above code runs well in python shell.
> >
> > However I have a problem as follows.
> >
> > new a file named test.py
> >
hollowspook schrieb:
> def aa():
> global b
> b=b+1
> print b
>
> b=1
> aa()
>
> The above code runs well in python shell.
>
> However I have a problem as follows.
>
> new a file named test.py
>
>
> def aa():
"hollowspook" <[EMAIL PROTECTED]> wrote:
> from test import *
> b=1
> aa()
>
> The error message is :
> Traceback (most recent call last):
> File "", line 1, in ?
> File "test.py", line 3, in aa
> b=b+1
> NameError: global name 'b' is not defined
>
> Why this happens? Please do me a favo
def aa():
global b
b=b+1
print b
b=1
aa()
The above code runs well in python shell.
However I have a problem as follows.
new a file named test.py
def aa():
global b
b=b+1
print b
-