Random string generation with upper case letters and digits

前端 未结 30 3225
逝去的感伤
逝去的感伤 2020-11-22 02:51

I want to generate a string of size N.

It should be made up of numbers and uppercase English letters such as:

  • 6U1S75
  • 4Z4UKK
  • U911K4
30条回答
  •  梦毁少年i
    2020-11-22 02:55

    If you want an easy-to-use but highly customisable key generator, use key-generator pypi package.

    Here is the GitHub repo where you can find the complete documentation.

    You can customise it to give a string jist like you want with many more options. Here's an example:

    from key_generator.key_generator import generate
    
    custom_key = generate(2, ['-', ':'], 3, 10, type_of_value = 'char', capital = 'mix', seed = 17).get_key()
    print(custom_key)  # ZLFdHXIUe-ekwJCu
    

    Hope this helps :)

    Disclaimer: This uses the key-generator library which I made.

提交回复
热议问题