如何使用命令重新启动python脚本

如何使用命令重新启动python脚本,python,Python,因此,我在重新启动脚本本身时遇到了麻烦。我正在制作一个简单的程序,我想有一个选择,例如: print ('would you like to make another calculation') choice3 = input(' Choose: [Y], [N]') if choice3.lower() == 'y': print ('OK!') time.sleep(3) 我想让它重新启动。如果有人能帮我,谢谢。。。我非常感谢您可以使用循环: while True:

因此,我在重新启动脚本本身时遇到了麻烦。我正在制作一个简单的程序,我想有一个选择,例如:

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

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

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

我想让它重新启动。如果有人能帮我,谢谢。。。我非常感谢

您可以使用
循环

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

您可以使用
循环
执行此操作:

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

我建议使用while循环,而不是重新启动脚本。我建议使用while循环,而不是重新启动脚本。这非常有效。谢谢,我真的很感激它工作得很好。谢谢,我真的很感激