栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Python

python中print()换行的问题

Python 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

python中print()换行的问题


title: python中print()换行的问题
date: 2022-04-17 14:36:12
tags:
- python使用
- python学习
categories: python
python中print()换行的问题

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_workwork1.py ====================================
第一行
第二行
第一行
第二行
--------------------------
第一行*第二行

一直print(),一直换行,哈哈哈哈哈

print()
print()
print()
print()
print()

结果:

===================================== RESTART: G:python_workwork1.py ====================================






o

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/971642.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号