Python的print()函数详解

name = 'Ghost'
age = 18
print(
    "My name is ",name,"."
    "I'm ",age, " years old",".",
    sep = ''
)

参数 sep默认为空格

name = 'Ghost'
age = 18
print("My name is",name+".",end='')
print("I'm",age,"years old.")

参数end默认为换行符(\n)

 

name = 'Ghost'
age = 18

print("My name is %s,I'm %d years old"%(name,age))

格式化输入 %s、%d占位符,分别接受任意字符和数字

posted @ 2019-10-31 14:33  GhostAnt  阅读(1291)  评论(0编辑  收藏  举报