%s是万能的,可以传数字,列表
msg = ‘i am %s my hobby is alex‘ %‘lhq‘
msg2 = ‘i am %s ,my hobby is %s‘ %(‘lhq‘,‘play‘)
print(msg)
print(msg2)
####s前加(.3)意思是截取字符串前三个元素
# %d只能传数字
k = ‘jack is %d‘ %22
print(k)
##用分隔符链接每一个字符
print(‘root‘,‘x‘,‘0‘,‘0‘,sep=‘:‘)
输出结果:
root:x:0:0