python 全局变量
PHP中文网
PHP中文网 2017-04-17 17:49:55
0
1
464

python 中的全局变量是什么概念?是在一个模块中定义的,它的作用域是什么?在一个文件中定义的全局变量,在其它的文件中要使用那个变量要怎么使用呢?
有没有那种像C语言的中的全局变量一样,然后在整个程序中都可以用的?

PHP中文网
PHP中文网

认证高级PHP讲师

reply all(1)
PHPzhong

If you want to use C language, you have to declare it as extern. Python just needs to be imported.

a.py:
AAA='AAA'

b.py:
from a import AAA
print AAA
AAA='123'

By default, the scope is only the file that defines it. To use other files, you need to import

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!