【发布时间】:2014-05-27 14:03:51
【问题描述】:
所以,我可以这样做:
>>> '%.4x' % 0x45f
'045f'
但我需要从变量中传递 4,smth 之类的
>>> digits=4
>>> '%.'+str(digits)+'x' % 0x45f
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: not all arguments converted during string formatting
【问题讨论】:
标签: python formatting format number-formatting