嘿,大家我介紹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個。 –