执行程序时遇到错误:NameError:name‘XXX’is not defined
i = int(raw_input('输入利润:')) arr = [1000000,600000,400000,200000,100000,0] rat = [0.01,0.015,0.03,0.05,0.075,0.1] r = 0 for idx in range(0,6): if i>arr[idx]: r+=(i-arr[idx])*rat[idx] print (i-arr[idx])*rat[idx] i=arr[idx] print (r)
执行:
Traceback (most recent call last):
File "D:/pythonProject/pythonProject3/.idea/新建包/1.py", line 5, in
i = int(raw_input('输入利润:'))
NameError: name 'raw_input' is not defined
原因分析:
其实是python3删除了raw_input,用等效的代码input替代即可
解决方案:
将raw_input改成input
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)