網上有說在print語句後面加上逗號,輸出的語句就不會換行,但是試了下各種情況,包括逗號和分號,都會換行,有哪位知道這是什麼情況?
for i in range(0,5):
print(i,)
0
1
2
3
4
for i in range(0,5):
print(i)
0
1
2
3
4
for i in range(0,5):
print(i),
0
(None,)
1
(None,)
2
(None,)
3
(None,)
4
(None,)
for i in range(0,5):
print(i);
0
1
2
3
4
添加end
for x in range(0, 5):
print(x, end = "");