我刚刚安装了Visual Studio 2017用于python编码。我是python的新手。我在Visual Studio中弄乱了python,在我尝试创建的第一个.py文件中,它无法在Visual Studio中运行。
在IDLE中打开.py,它运行良好且运行完美。在Visual Studio中,会弹出一个对话框,说“按任意键继续...”,然后关闭。调试输出显示:
The thread 0x1 has exited with code 0 (0x0).
The program 'python.exe' has exited with code 0 (0x0).
该程序最初可以在Visual Studio中正常运行,但会随机停止,并且在重新安装Visual之后仍然无法运行。
我的程序的代码是:
def calculateMean(numbers):
sum = 0
for i in numbers:
sum += numbers
mean = sum / len(i)
return mean
def quadraticFormula(a,b,c):
numeratorRoot = ((b**2)-(4*a*c))**(1/2)
firstResult = ((b*-1)+numeratorRoot)/(2*a)
secondResult = ((b*-1)-numeratorRoot)/(2*a)
return firstResult,secondResult
if __name__ == "__main__":
first = int(input("pick a: "))
second = int(input("pick b: "))
third = int(input("pick c: "))
result1,result2 = quadraticFormula(first,second,third)
print("The results are: R1={0} R2={1}".format(result1,result2))