python %s占位符的使用

#单个占位符使用%

myscore =1000

message = 'I scored %s ponits'

print message % myscore

 

#多个占位符的使用

firstName = "xiao11wang"

lastName = "dana"

name = 'my name is %s %s'

print name % (firstName,lastName)

编译结果:

I scored 1000 ponits

my name is xiao11wang dana

你可能感兴趣的:(python)