python print不换行

python中的print()函数会自动换行

有时希望能够不换行,则使用 print(str, end=' ')

print("hello world")
print("!")
# 输出结果为  hello world
            !

# 实现不换行
print("hello world", end=' ')
print("!")
# 输出结果为  hello world !

猜你喜欢

转载自blog.csdn.net/sinat_26871259/article/details/85336986