|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
看了小甲鱼视频,写了一段1加到100的代码,结果如图:(晕 了,不会传图,没反应)
Python 3.11.0 (main, Oct 24 2022, 18:26:48) [MSC v.1933 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license()" for more information.
i = 1;
a = 0;
while i <= 100 :
print(i)
a += i
i += 1
print(a)
SyntaxError: multiple statements found while compiling a single statement
- while i <= 100 :
- print(i)
- a += i
- i += 1
复制代码分别是4条语句,要逐条输入
错误: - >>> i = 1;
- a = 0;
- while i <= 100 :
- print(i)
- a += i
- i += 1
- print(a)
- SyntaxError: multiple statements found while compiling a single statement
复制代码正确:
- >>> i = 1;
- >>> a = 0;
- >>> while i <= 100:
- print(i)
- a += i
- i += 1
-
- 1
- 2
- 3
- 4
- # ... 此处省略 5~99 ... #
- 100
- >>> print(a)
- 5050
- >>>
复制代码
|
|