python如何使输出换行
python的print()函数输出时,通常输出结果是整行显示出来的,这时候我们需要考虑一下,我们输出的结果需不需要换行?
不需要换行的方法也是嗯容易的的,这里就不多赘述了,来说说如何做到输出换行:
常用的转义符方式:\n
#-*-coding:utf-8-*-
A="来看看能不能\n换行。"
print(A)
输出结果
来看看能不能
换行。
使用三引号进行换行:"""value1;value2;value3."""
#-*-coding:utf-8-*-
print("""
这是第一行;
这是第二行;
""")
输出结果
这是第一行;
这是第二行;
通常我们使用两个print()的时候,输出结果会两行显示,呐!最后再提供一种两个print()同行输出的方法:end=''
#-*-coding:utf-8-*-
A="我想要"
B="money。"
print(A,end='')
print(B)
输出结果
我想要money。
以上内容为大家介绍了python培训之如何使输出换行,希望对大家有所帮助,如果想要了解更多Python相关知识,请关注IT培训机构:千锋教育。

相关推荐HOT
更多>>
pythonprint函数如何不换行
python3.0的print函数有如下的形式:print([object,...][,seq=''][,end='\n'][,file=sys.stdout])我们在...详情>>
2023-11-09 19:52:59
转java还是python?
从目前IT行业的人才需求上来看,如果是应用级开发,那么掌握Java语言会更容易实现就业,因为在目前的生产环境下,Java语言凭借其健全的语言生态...详情>>
2023-11-09 18:02:00
python中怎么对一个数进行因式分解?
1、Python因式分解代码:importtime#对一个数进行因式分解deffactorization(num):factor=[]whilenum>1:foriinrange(num-1):k=i...详情>>
2023-11-09 12:01:26
python如何让程序暂停执行和继续执行?
python让程序继续执行的方法:一、使用到的函数或库1.cv2.imshow()2.cv2.waitKey()3.time.sleep()4.cv2.putText()5.np.zeros()二、程详情>>
2023-11-09 11:03:08