0

これがやろうとしていることです:

l = 4
length = 10**l #10000
for x in xrange(length): 
   password = str(username)+str("%02d"%x) #but here instead of 2 i want it to be l

ご覧のとおり、私は自分でできる変数魔女でフォーマット文字列を制御したいので、次のようにしようとしました:

password = str(username)+str("%0"+str(l)+"d"%x)  

しかし、それは私に次のことを伝えるエラーを与えます:文字列のフォーマット中にすべての引数が変換されるわけではありません

4

1 に答える 1