2017-10-17 10 views
0

これで、スクリプト自体を再起動する際に問題が発生しています。私は簡単なプログラムを作っています。例えば、次のような選択肢を持っています:コマンドでpythonスクリプトを再起動するにはどうすればいいですか

print ('would you like to make another calculation') 

choice3 = input(' Choose: [Y], [N]') 

if choice3.lower() == 'y': 
    print ('OK!') 
    time.sleep(3) 

そして私はそれをすぐに再開したいと思います。誰も私を助けることができる場合に感謝...私は本当に

+0

私の代わりにスクリプトを再起動するのwhileループを使用してお勧めします。 [このように](https://stackoverflow.com/questions/20337489/python-how-to-keep-repeating-a-program-until-a-specific-input-is-obtained) – MisterMystery

答えて

2

それを感謝し、あなたはloopを使用してこの操作を行うことができます。

while True: 
    print ('would you like to make another calculation') 
    choice3 = input(' Choose: [Y], [N]') 
    if choice3.lower() == 'y': 
     print ('OK!') 
     time.sleep(3) 
    else: 
     break 
+0

これは完全に機能しました。ありがとう、本当にありがとう – LostRoninYT

関連する問題