zoukankan      html  css  js  c++  java
  • python代码实现自动化测试中字符串自动生成

    import datetime
    import random
    import string

    t1 = datetime.datetime.today()
    t1 = t1.strftime("%Y%m%d%H%M%S")
    print(t1)

    print("大小写字母:" + string.ascii_letters)
    print("小写字母:" + string.ascii_lowercase)
    print("大写字母:" + string.ascii_uppercase)
    print("数字:" + string.digits)
    print("特殊符号:" + string.punctuation)
    print("可打印的字符:" + string.printable)
    print("空格字符:" + string.whitespace)
    StringS = ''.join(random.sample(string.digits+string.ascii_letters,32))
    print(StringS)

    #指定字符集输出
    seed = "1234567890"
    str1 = []
    for i in range(18):
    str1.append(random.choice(seed))
    String1 = ''.join(str1)
    print(String1)
    #指定长度输出
    def newstr(len):
    seed="1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
    str1=[]
    for i in range(len):
    str1.append(random.choice(seed))
    string2 = ''.join(str1)
    print(string2)
    #len22 = int(input("请输入字符串的长度:"))
    newstr(18)
  • 相关阅读:
    JS闭包
    webpack管理资源
    在webpack中使用配置文件
    webpack起步
    buuctf-MISC 面具下的flag
    Kali linux Steghide开源隐写工具
    buuctf-misc 九连环
    buuctf-Crypto rsarsa 1
    buuctf-web HardSQL 1
    buuctf-web Hack World 1
  • 原文地址:https://www.cnblogs.com/51testing/p/15550157.html
Copyright © 2011-2022 走看看