1.使用zfill填充

str(random.randint(0,99999999)).zfill(8)

2.

import string

"".join(map(lambda x:random.choice(string.digits), range(8)))

3.使用random sample

import random

random.sample(["0","1","2","3","4","5","6","7","8","9"],8)

 

相关文章:

  • 2021-09-19
  • 2021-08-16
  • 2021-12-09
  • 2021-12-09
  • 2022-12-23
  • 2021-11-30
  • 2022-12-23
  • 2023-02-14
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-12
  • 2021-05-17
  • 2022-12-23
相关资源
相似解决方案