我创建了一个菜单,可以在其中显示用户输入的变量。如果用户什么都不输入,则默认设置。问题是我在执行模块时收到错误。默认设置的变量:tab = "True" 和 amount = "N/A"
代码:def menu(): print(""" * = Optional
1. Start the application.
2. Set crate.
3. Set link for crate. *
4. Settings. *
""")
menu_qsone = str(input("> "))
if menu_qsone == "4":
clear()
settings()
def settings():
print("Settings: ")
print("1. Open a tab when the program is launched." + (tab))
print("2. Times the script will be used." + (amount))
print("3. Return to menu.")
qs_one = str(input("> "))
if qs_one == "1":
clear()
if tab == "True":
tab = "False"
clear()
settings()
if tab == "False":
tab = "True"
clear()
settings()
if qs_one == "2":
clear()
print("How many times would you like to run the script?")
qs_two = str(input("> "))
amount = (qs_two)
clear()
settings()
if qs_one == "3":
clear()
menu()
menu()
错误;
Traceback (most recent call last):
File "C:\Users\Stagiair\Desktop\PauzeProject\MainFile.py", line 63, in <module>
menu()
File "C:\Users\Stagiair\Desktop\PauzeProject\MainFile.py", line 32, in menu
settings()
File "C:\Users\Stagiair\Desktop\PauzeProject\MainFile.py", line 36, in settings
print("1. Open a tab when the program is launched." + (tab))
UnboundLocalError: local variable 'tab' referenced before assignment
慕桂英4014372
相关分类