這可能是一個非常非常基本的愚蠢問題,但我無法管理如何做到這一點;我有這樣的菜單(在Python 3):啓動一個模塊到Python菜單
boucle = True
while boucle:
print('''
1−Gestion de listes
2−Gestion de matrices
0-Quitter
''')
choix = input('Choissisez une commande:')
if choix == '1':
gestionliste()
elif choix == '2':
print('Gestions de matrices')
elif choix == '0':
boucle = False
else:
print('Entrée erronée:Veuillez entrez loption 1,2 ou 0')
(是的,它是寫在法國的方式),我想,當用戶輸入「1」作爲一個選擇,我想使它啓動我在同一個.py文件中創建的函數,例如def thefunction():
我想要菜單在用戶輸入'1'時啓動thefunction()
函數。我嘗試了很多東西,比如(從if choix=='1'
)函數(),導入函數(),從file.py導入()...並沒有任何作用。我沒有找到正確的方法來做到這一點,我猜?
非常感謝,它實際上是隻是因爲我在菜單後面寫了def函數;之前我複製並粘貼了它,它像魅力一樣工作;謝謝! –