我试图在列表中的每个数字前面添加零,如果它不是必要的数字位数.
lst = ['1234','2345'] for x in lst: while len(x) < 5: x = '0' + x print(lst)
理想情况下,这将打印['012345','02345']
python string list prepend python-3.x
list ×1
prepend ×1
python ×1
python-3.x ×1
string ×1