2015-11-07 45 views
0

我目前正在學習Python編程。我使用這個模塊的目標是在文件中輸入一些數據,我希望用戶能夠多次執行。但是,我的while循環只會執行一次,即使我在最後按「1」,它也不會再執行。while循環,不會在Python 3.5中運行

ctl = 1 
while ctl == 1: 

    print("\n") 


    titre = input("Nom du film : ") 
    année = input("Année : ") 
    catégorie = input("Catégorie : ") 


    fichier = open("Data_Film","a",encoding = "UTF-8") 
    fichier.write(titre + ";" + année + ";" + catégorie + "\n") 
    fichier.close() 

    print("\n") 
    print("1 - Ajouter un autre film") 
    print("2 - Menu principal") 


    ctl = input("Que vouez vous faire?") 

回答

1

您正在比較字符串與整數,並將始終爲假。

你需要做的:

ctl = int(input("Que vouez vous faire?")) 
+0

天哪謝謝! Ctrl + C Ctrl + V並不總是你的朋友!再次感謝! – Gaboik