python中print()换行的问题
python中print()换行的问题
·
title: python中print()换行的问题
date: 2022-04-17 14:36:12
tags:
- python使用
- python学习
categories: python
python使用print不换行输出
python的print()函数中参数end=’ ‘默认为\n,所以会自动换行。
默认的print()函数:
print(end=’\n’)
解决
把参数end=’ ‘设置成你想要的就行了,如end=’’,那么它就是以结尾
#默认使用end="\n"换行
#这两种效果一致
#一:
print("第一行",end='\n')
print("第二行")
#二:
print("第一行")
print("第二行")
print('--------------------------')
#使用*结尾
print("第一行",end="*")
print("第二行")
运行结果:
===================================== RESTART: G:\python\_work\work1.py ====================================
第一行
第二行
第一行
第二行
--------------------------
第一行*第二行
一直print(),一直换行,哈哈哈哈哈
print()
print()
print()
print()
print()
结果:
===================================== RESTART: G:\python\_work\work1.py ====================================
o
更多推荐
已为社区贡献1条内容
所有评论(0)