关于python3中,print函数,可以同时打印输出多个和多种类型数据,如下:
>>> print(1,"abc",2,"https://www.cnblogs.com/5201351",True) 1 abc 2 https://www.cnblogs.com/5201351 True >>>
如上可以看出,各项默认以一个空格隔开,行尾符默认为\n换行符
1、其实print函数,是可以通过sep="xxx",指定这个默认分隔符的,这个有时可能会比较常用,如下
# 指定默认的分隔符,无论单个字符还是字符串,使用单引号和双引号都是可以的 print(1,"abc",2,"https://www.cnblogs.com/5201351",True,sep='\t') print(1,"abc",2,"https://www.cnblogs.com/5201351",True,sep="@@@")
2、还可以指定行尾符,也可以去掉行尾符,如下:
# 通过end="xxx",指定,单双引号都可以的 print(1,"abc",2,"https://www.cnblogs.com/5201351",True,end='!') print(1,"abc",2,"https://www.cnblogs.com/5201351",True,end="!\n") # 去掉最后的行尾符,其实也即是将行尾符,设置为空字符串 print(1,"abc",2,"https://www.cnblogs.com/5201351",True,end='') print(1,"abc",2,"https://www.cnblogs.com/5201351",True,end="")
尊重别人的劳动成果 转载请务必注明出处:https://www.cnblogs.com/5201351/p/14900979.html