python的os.urandom 的用途

Python中os.urandom(n)的作用

随机产生n字节(0-255)的字符串,可以作为随机加密key使用~

 

 

[python] view plain copy
  1. >>> index = os.urandom(2)  
  2. >>> print index  
  3. 墿  
  4. >>> index = os.urandom(2)  
  5. >>> print index  
  6. 氡  
  7. >>> index = os.urandom(2)  
  8. >>> print index  
  9. Ε  
  10. >>> index = os.urandom(2)  
  11. >>> print index  
  12. E'  
  13. >>> index = os.urandom(2)  
  14. >>> print index  
  15. €H  
  16. >>> index = os.urandom(2)  
  17. >>> print index  
  18. I?  
  19. >>> index = os.urandom(2)  
  20. >>> print index  
  21. ?? 
posted @ 2018-03-07 14:07  长白山  阅读(1396)  评论(0编辑  收藏  举报