python局部变量实例
2015-08-18 21:21
531 查看
def Fun1(): x = 5 def Fun2(): x*=x return x return Fun2() 上面程序有问题,修改方法如下两种方案: def Fun1(): x = [5] def Fun2(): x[0] *= x[0] return x[0] return Fun2() def Fun1(): x = 5 def Fun2(): nonlocal x x*=x return x return Fun2()
相关文章推荐
- python实现大文件分割与合并
- python中迭代器和iter()函数
- python *和**
- Mac自带Python版本升级
- python 使用pymsql连接数据库
- python 之 requests 模块
- Python笔记一
- 【Python】[面向对象编程] 访问限制,继承和多态
- Python nltk -- Sinica Treebank
- Python中有关list的增删改查
- python学习--windows下安装Numpy包的错误:Unable to find vcvarsall.bat
- python第三方库系列之二十二--subprocess的用法
- python视频教程大全集下载啦!超级全的教程!
- 我第一个Python教程笔记
- python中的有序字典OrderedDict
- Python3与Python2的区别
- 15 正则表达式 - 《Python 核心编程》
- Python学习 windows下面安装Python和pip(一)
- 14 执行环境 - 《Python 核心编程》
- python之路-----搭建django框架