格式化
format
>>> "{0} love {1}".format(‘I‘,‘python‘) ‘I love python‘ >>> "{a} love {b}".format(a=‘I‘,b=‘python‘) ‘I love python‘ 位置参数必须在关键字参数之前 >>> "{0} love {b}".format(‘I‘,b=‘pytnon‘) ‘I love pytnon‘ >>> "{a} love {0}".format(a=‘I‘,‘python‘) Error>>> "{0:.1f}{1}".format(88.888,"GB")‘88.9GB‘
>>> ‘%c‘%97 ‘a‘ >>> ‘%d %d %d‘%(1,2,4) ‘1 2 4‘ >>> ‘%e‘%12345 ‘1.234500e+04‘ #在八进制前显示(‘0o’),在16进制前显示(‘0x’)或(‘0X’)、 >>> ‘%#o‘%10 ‘0o12‘ >>> ‘%#x‘%10 ‘0xa‘ >>> ‘%#d‘%10 ‘10‘
相关推荐
Noneyes 2020-11-10
huavhuahua 2020-11-20
weiiron 2020-11-16
ailxxiaoli 2020-11-16
cakecc00 2020-11-15
千锋 2020-11-15
JakobHu 2020-11-14
chensen 2020-11-14
Nostalgiachild 2020-11-13
guangcheng 2020-11-13
zhangxiafll 2020-11-13
jipengx 2020-11-12
xirongxudlut 2020-11-10
solarLan 2020-11-09
pythonxuexi 2020-11-08
文山羊 2020-11-07
susmote 2020-11-07
wuShiJingZuo 2020-11-05
Pythonjeff远 2020-11-06