嘿,大家我介绍python编程,我们正在做第一个独立的代码。分配如下:UnboundLocalError:分配前引用的局部变量'print'
Prompt the user for his or her name. Then prompt the user for two numbers and then perform a mathematical operation of your choice on them. Make sure the program works with decimal numbers, and that you print a full equation in response, not just the result: Enter a number: 2.3 Enter another number: 3.6 2.3 – 3.6 = -1.3
所以我进入:
def main1():
print("This is program 1!")
name = input("Please enter your name: ")
print("Pleased to meet you,", name ,"!") #next line def main2():
print("This is program 2!")
import math
number = input("Enter a number: ")
number = float(number)
numberr = input("Enter another number: ")
numberr = float(numberr)
print = ("number + numberr")
我不停的得到这个:
UnboundLocalError: local variable 'print' referenced before assignment
帮助!
[Python变量范围错误(可能的重复http://stackoverflow.com/questions/370357/python-可变范围错误) –
Stack Overflow上有'UnboundLocalError'的重复项。屏幕的右侧应显示至少10个。 –