热线电话:13121318867

登录
2018-12-03 阅读量: 879
print中的结束参数是什么?

默认情况下,python的print()函数以换行符结束。具有C / C ++背景的程序员可能想知道如何在没有换行的情况下进行打印。
Python的print()函数带有一个名为'end'的参数。默认情况下,此参数的值为'\ n',即换行符。您可以使用此参数结束包含任何字符/字符串的print语句。

# This Python program must be run with

# Python 3 as it won't work with 2.7.

# ends the output with a <space>

print("Welcome to" , end = ' ')

print("GeeksforGeeks", end = ' ')

另一个演示结束参数工作的程序。

# This Python program must be run with

# Python 3 as it won't work with 2.7.

# ends the output with '@'

print("Python" , end = '@')

print("GeeksforGeeks")

0.0000
2
关注作者
收藏
评论(0)

发表评论

暂无数据
推荐帖子