溫馨提示×

python怎么打印在同一行

小億
134
2024-09-25 23:21:07
欄目: 編程語言

在Python中,您可以使用end參數在print函數中指定行尾字符。默認情況下,end參數的值是換行符\n,這意味著每次調用print函數時,都會在輸出中添加一個新行。

如果您想在同一行上打印多個項目,可以將end參數設置為空字符串''或空格' '。以下是一些示例:

使用空字符串''

print('Hello', 'world!', end='')
print('We are on the same line.')

輸出:

Hello world! We are on the same line.

使用空格' '

print('Hello', 'world!', end=' ')
print('We are on the same line.')

輸出:

Hello world! We are on the same line.

0
亚洲午夜精品一区二区_中文无码日韩欧免_久久香蕉精品视频_欧美主播一区二区三区美女