day13 百分号拼接

#1. 字符串使用%s  %S可以接收任何类型的值
# msg = ('i am  %s my hobby is %s' %('lhf','alex'))
# sg = ('i am  %s my hobby is %s' %('lhf',[1,2]))
# print(msg)


# 2.%d只能接收int 类型
# msg = ('i am  %s my hobby is %d' %('lhf',1))

# print(msg)

# name = 'pxf'
# age = 18
# names = ('i am is my %s  yeas old %d' %(name,age))
# print(names)


# 打印浮点数,%f 在百分号后加数字.1, .2, .3表示留几个小数点
# tpl = 'percent %.2f'  %99.976234444444
# print(tpl)



# 打印百分比
# tpl = 'percent %.2f %%'  %99.976234444444
# print(tpl)



tpl = 'i am  \033[43;1m%(name)+60s\033[0m my hobby is alex' %{'name':'alex','age':18}
print(tpl)



print('root','x ','0',' 0',sep =':')

  

猜你喜欢

转载自www.cnblogs.com/styelfang/p/10180489.html
今日推荐