safe enough 8-character short unique random string

前端 未结 7 1358
甜味超标
甜味超标 2021-02-01 01:34

I am trying to compute 8-character short unique random filenames for, let\'s say, thousands of files without probable name collision. Is this method safe enough?



        
7条回答
  •  栀梦
    栀梦 (楼主)
    2021-02-01 02:29

    Your current method should be safe enough, but you could also take a look into the uuid module. e.g.

    import uuid
    
    print str(uuid.uuid4())[:8]
    

    Output:

    ef21b9ad
    

提交回复
热议问题