alansuny

导航

 
#### Python:practice random module for verification code program
  1. randomly create 5-bit verification mix numbers and alphabet

    1. contain command random.randint,random.randrange.

      1. python code

      2. def v_code():
            code=''
            for i in range(5):
                if i ==random.randrange(0,2)
                   add=random.randrange(10)
                 else:
                    add=chr(random.randomrange(65,91))
                 code+=str(add)
             print(code)
            
            
            def v_vode()
        
  2. implement random.choice command is simple to realize the purpose

    def v_code():
        code=''
        for i in range(5):
            add=random.choice[random.randrange(10),chr(random.randrange(65,91))]
            code+=str(add)
         print(code)
      v_code()
            
    
    1. it perfect

      • ok

posted on 2020-03-17 16:52  alansuny  阅读(6)  评论(0编辑  收藏  举报