我編寫了一個代碼。我將它保存爲「.py」。但是當我打開它時,一個黑色的控制檯會回來。所以我看不到錯誤。我的代碼:Python腳本不運行
import time
def average(numb1, numb2, numb3):
while true:
result = numb1 + numb2 + numb3
print('The average is' + str(average) + '\n')
time.sleep(3)
def main():
while true:
num1 = input('Enter the first number > ')
try:
num1 = float(num1)
except ValueError:
print('Please enter a number !\n')
continue
num2 = input('Enter the first number > ')
try:
num2 = float(num2)
except ValueError:
print('Please enter a number !\n')
continue
num3 = input('Enter the first number > ')
try:
num3 = float(num3)
except ValueError:
print('Please enter a number !\n')
continue
average(num1, num2, numb3)
try:
main()
except KeyboardInterrupt:
print('\n\nKeyboard exception received. Exiting.')
exit()
如果我解決了這個問題,我將非常高興。謝謝 !
這是'真',而不是'真'。 – 101
從終端運行腳本或使用IDE。 –
你如何運行腳本? –