字符串的拼接

msg="I am "+"king"
print(msg)
print("I am %s of the %s" % ("tang","king"))#%s 字符串占位符

print("I am %s of age %s" % ("tang",[20,11]))#%s 字符串占位符


print("I am %s of the %d" % ("tang",1))#%d 整型占位符


#打印浮点数
print("I am %s of the  mailes %.2f" % ("tang",1.12233))#%f 浮点型占位符 .2表示只取两位小数

#打印百分号
print("percent %.2f %%%d" % (1.12233,80))#%%


print("I am %(name)s of the age %(age)d" % {'name':"tang","age":21})#字典键进行传值


print('root','x', '0','0',sep=":")
如果我失败了,至少我尝试过,不会因为痛失机会而后悔
原文地址:https://www.cnblogs.com/tangcode/p/10965560.html