为什么它在第 1 行(python3.13)中给我无效的语法

问题描述 投票:0回答:1

代码:

 print("Welcome to my Calculator!!")
 nb1 = int(input("Enter the 1st number: "))
 nb2 = int(input("Enter the 2nd number: "))
 A = nb1 + nb2 
 S = nb1 - nb2
 M = nb1*nb2
 D = nb1//nb2
 print("The addition of " , nb1 , "+" , nb2 ,"is:", A)
 print("The subtraction of " , nb1 , "-" , nb2 ,"is:", S)
 print("The multiplication of " , nb1 , "x" , nb2 ,"is:", M)
 print("The division of " , nb1 , "/" , nb2 ,"is:", D)

说实话我不知道该怎么办。它只能在 python 调试器中工作

错误信息:

 File "<python-input-21>", line 1
    & C:/Users/user1/AppData/Local/Programs/Python/Python313/python.exe "c:/Users/user1/Desktop/homework 2.py"
    ^
SyntaxError: invalid syntax
>>>
python
1个回答
0
投票

您正在尝试运行此:

C:/Users/user1/AppData/Local/Programs/Python/Python313/python.exe "c:/Users/user1/Desktop/homework 2.py"

就好像它是Python代码一样。

这应该在命令提示符下输入。 这不是Python代码。

© www.soinside.com 2019 - 2024. All rights reserved.