python list中str转化int ++ 补零

a = ['1','2','3']
b = [int(i) for i in a]          # 将list中字符串变为int型 此时b = [1,2,3]

c = [(i-1) for i in b]           # 循环减1   c = [0,1,2]

for i in range(len(c)):
    c[i] = "%02d" % c[i]         # 格式化为两位数   c = [00,01,02]

你可能感兴趣的:(python)