python定义全局变量的方法
小编给大家分享一下 python定义全局变量的方法,希望大家阅读完这篇文章后大所收获,下面让我们一起去探讨方法吧!
python定义全局变量的方法:
python需要用到关键字“global 变量名”的方式来定义全局变量。
例如:定义全局变量student,“global student”就代表定义了一个全局变量student
示例如下:
看完了这篇文章,相信你对 python定义全局变量的方法有了一定的了解,想了解更多相关知识,欢迎关注行业资讯频道,感谢各位的阅读!