|
发表于 2022-6-23 10:06:09
|
显示全部楼层
这个问题是源于变量作用域的问题,“user_Input_字符输入”这个变量是属于“主选择”这个类的,在 simple 这个文件的变量清单中并没有该变量名,虽然后面的 global 创建了该变量。
可改成
- # simple
- user_Input_字符输入 = None
- class 主选择():
- def logo():
- print(" _ _ _ \n"
- "| | (_) | | \n"
- "| | ___ _ __ ___ ___ _ __ ___ _ _ __ ___ _ __ | | ___ \n"
- "| |/ _ \| '_ ` _ \ / _ \ '_ \ / __| | '_ ` _ \| '_ \| |/ _ \ \n"
- " | | (_) | | | | | | __/ | | | \__ \ | | | | | | |_) | | __/ \n"
- "|_|\___/|_| |_| |_|\___|_| |_| |___/_|_| |_| |_| .__/|_|\___| \n"
- " | | \n"
- " |_| ")
- def 字符输入():
- global user_Input_字符输入
- user_Input_字符输入 = (str(input(">>>")))
-
复制代码
- # test
- import simple
- while True:
- user_Input = (str(input(">>>")))
- if user_Input == "logo":
- simple.主选择.logo()
-
- if user_Input == "字符输入":
- simple.主选择.字符输入()
- from simple import user_Input_字符输入
- print(user_Input_字符输入)
复制代码 |
|