I'm trying to auto-restart this program, language is Italian.
import sys
import os
#semplice calcolatrice
def addizione(x,y):
return x + y
def sottrazione(x,y):
return x - y
def moltiplicazione(x,y):
return x * y
def divisione(x,y):
return x/y
def potenza(x,y):
return pow(x, y)
#imput dall'utente
print("Seleziona l'operazione.")
print("1.addizione")
print("1.sottrazione")
print("1.moltiplicazione")
print("1.divisione")
print("1.potenza")
choice=input("Inserisci 1/2/3/4/5: ")
num1=int(input("Inserisci il primo numero: "))
num2=int(input("Inserisci il secondo numero: "))
if choice == '1':
print(num1, "+", num2,"=", addizione(num1,num2))
elif choice == '2':
print(num1, "-", num2,"=", sottrazione(num1,num2))
elif choice == '3':
print(num1, "*", num2,"=", moltiplicazione(num1,num2))
elif choice == '4':
print(num1, "/", num2,"=", divisione(num1,num2))
elif choice == '5':
print(num1, "^", num2,"=", potenza(num1,num2))
else:
print("Input invalido")
choice=input("Nuovo calcolo: 1, Chiudi: 2 > ")
if choice == '1':
os.execv(__file__, sys.argv)
elif choice == '2':
exit()
I searched in other answer and i found this os.execv(__file__, sys.argv)
.
It shows me this error at the end if I try to "restart" the calculator Traceback (most recent call last):
File "C:\Users\ruben\eclipse-workspace\prove\test\calcolatrice.py", line 57, in <module>
os.execv(__file__, sys.argv)
OSError: [Errno 8] Exec format error
.
Using Python in Eclipse with PyDev, thanks for the help!