关于输出
- Python3:换行输出,不换行输出
- Python3:占位符输出
Python3:换行输出,不换行输出
# -*- coding: UTF-8 -*-
# Python 关于换行输出
print("Hello world", end="") # 参数end的内容,代表如果是文本空:"",那么就不会换行并结尾不追加文本
print("Hello world", end=" ")#如果有内容" "(一个空格),那么就会有一个空格
print("Hello world", end=" And ")#如果有内容英文And,那么结尾就会出现一个And
print("Hello world", end=None)#如果是None(空),就会换行
print("Hello world", end="")#如果是None(空),就会换行
Python3:占位符输出
# -*- coding: UTF-8 -*-
# Python 关于占位符输出
print ("床前%s光"%("明月"))
#得到结果:床前明月光
print ("李白的《静夜思》创作于唐玄宗开元十四年(%d年)九月十五日的扬州旅舍,时李白%d岁。"%(726,26))
#得到结果:李白的《静夜思》创作于唐玄宗开元十四年(726年)九月十五日的扬州旅舍,时李白26岁。
上面的 " %s " 是格式符,可以参考链接:blog.csdn.net/qq_36051316…