1
chr(c)
1
ord(c)
1
2
3
4
5
6
# 123
int('123')
# 22
int('10110', 2) # 基数范围 [2, 36]
# 123.987
float('123.987')
1
2
# '0b10110'
bin(22)
1
2
3
4
5
6
7
8
9
10
# %[(name)][flags][width][.precision]typecode
# '+00123.334'
'%+010.3f' % 123.3335
# ' +123.334'
'%+10.3f' % 123.3335
# '+123.334 '
'%-+10.3f' % 123.3335
# 'jim is 10 years old.'
'%(name)s is %(age)d years old.' % {'name': 'jim', 'age': 10}