白月黑羽今天给大家分享另外一个冷知识:)
python中 print函数打印信息时默认添加一个换行符,所以你看到一条print语句,则单独占一行,那是否可以不要换行符呢?
答案是肯定的,当然可以,可用用end=” “参数告诉print()用你想要的任何字符代替换行符,示例如下:
print('Learn python with BYHY!')
print('Learn python with BYHY!') print('Learn python with BYHY!', end=' - once again - ')
print('Learn python with BYHY!')
输出结果:
Learn python with BYHY!
Learn python with BYHY! Learn python with BYHY! - once again - Learn python with BYHY!
更多内容,请直接访问:白月黑羽 Python3教程