詹惠儿

2019-01-05   阅读量: 553

数据分析师

python如何在没有换行的情况下输出

扫码加入数据分析学习群

默认情况下,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")

添加CDA认证专家【维克多阿涛】,微信号:【cdashijiazhuang】,提供数据分析指导及CDA考试秘籍。已助千人通过CDA数字化人才认证。欢迎交流,共同成长!
0.0000 0 1 关注作者 收藏

评论(0)


暂无数据

推荐课程

推荐帖子