UnboundLocalError: local variable 'sum1' referenced before assignment
来源:互联网 发布:出国gpa算法 知乎 编辑:程序博客网 时间:2024/05/01 07:16
sum1=0def ni():sum1=sum1+2return sum1for i in iter(ni,8):print i
出现UnboundLocalError: local variable 'sum1' referenced before assignment
改正:
sum1=0def ni():global sum1#定义为全局变量sum1=sum1+2return sum1for i in iter(ni,8):print i
阅读全文
0 0
- UnboundLocalError: local variable 'sum1' referenced before assignment
- Python - UnboundLocalError: local variable referenced before assignment
- UnboundLocalError: local variable 'l' referenced before assignment
- UnboundLocalError: local variable 'l' referenced before assignment
- UnboundLocalError: local variable ' ' referenced before assignment
- UnboundLocalError: local variable 'XXX' referenced before assignment
- UnboundLocalError: local variable 'c' referenced before assignment
- UnboundLocalError: local variable 'epoch_logs' referenced before assignment
- 【Python】UnboundLocalError: local variable 'l' referenced before assignment
- 全局变量报错:UnboundLocalError: local variable 'l' referenced before assignment
- 【Python基础】之全局变量(UnboundLocalError: local variable referenced before assignment)
- 【Python】UnboundLocalError: local variable 'l' referenced before assignment
- 全局变量报错:UnboundLocalError: local variable 'l' referenced before assignment
- 全局变量报错:UnboundLocalError: local variable 'i' referenced before assignment
- 【python】UnboundLocalError: local variable 'counter' referenced before assignment
- python的UnboundLocalError: local variable 'xxx' referenced before assignment
- python:UnboundLocalError: local variable 'l' referenced before assignment
- 【Python】UnboundLocalError: local variable 'x' referenced before assignment
- 如何创建一个对象
- Fundebug能够捕获这些BUG
- 单片机时钟程序(9)lcd1602.h
- SuperTextView
- 【算法】冒泡排序(从小到大) 排序范围(0~n-1)n为数组元素个数
- UnboundLocalError: local variable 'sum1' referenced before assignment
- linux 安装mysql
- (9)计算人民币各个面额的数量
- SDWebImage 和MWPhotoBrower联合使用的时候加载进度的expectSize一直为0或-1
- 大数据性能调优之HBase的RowKey设计
- 基于深度学习的目标检测的研究进展2
- C语言的输入与输出
- 分类模型的评估方法-F分数(F-Score)
- 数组去重