; ;

经常使用的一些公共方法



    #随机生成字符串 def random_str(self, num): str = '' chars = 'AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz0123456789-_' length = len(chars) - 1 for i in range(num): str +=chars[random.randint(0, length)] return str #随机生成数字字符串 def random_int(self, num): str = '' chars = '0123456789' length = len(chars) - 1 for i in range(num): str +=chars[random.randint(0, length)] return int(str) #随机生成数字字符串+字母字符串 def random_rid(self, num=15): str = '' chars = '0123456789' chars1 = 'AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz0123456789' length = len(chars) - 1 length1 = len(chars1) - 1 for i in range(5): str +=chars[random.randint(0, length)] for i in range(num): str +=chars1[random.randint(0, length1)] return str

  记录经常使用的一些方法,不用每次都自己写

posted @ 2021-07-05 15:53  做梦的人-  阅读(67)  评论(0编辑  收藏  举报