• random


    #!/usr/bin/env python
    import random

    print(random.random())
    print(random.randint(1,3))#0-3
    print(random.randrange(3))#0-2
    print(random.choice('abcdef'))#
    print(random.sample('abcdefgh',2))
    print(random.uniform(1,3))#浮点
    a = [1,2,3,4,5,6,7]
    print(random.shuffle(a))#打乱
    print(a)

    print("-------------------")
    checkcode=''
    for i in range(4):
    #current=random.randint(0,9)
    #current = random.sample('0123456789abcdefghijk',1)
    current = random.randrange(0,4)
    if current == i:
    tmp=chr(random.randint(65,90))
    else:
    tmp = random.randint(0,9)
    checkcode += str(tmp)
    print(checkcode)


    #!/usr/bin/env python
    import random

    print(random.random())
    print(random.randint(1,3))#0-3
    print(random.randrange(3))#0-2
    print(random.choice('abcdef'))#
    print(random.sample('abcdefgh',2))
    print(random.uniform(1,3))#浮点
    a = [1,2,3,4,5,6,7]
    print(random.shuffle(a))#打乱
    print(a)

    print("-------------------")
    checkcode=''
    for i in range(4):
    #current=random.randint(0,9)
    #current = random.sample('0123456789abcdefghijk',1)
    current = random.randrange(0,4)
    if current == i:
    tmp=chr(random.randint(65,90))
    else:
    tmp = random.randint(0,9)
    checkcode += str(tmp)
    print(checkcode)
  • 相关阅读:
    cocos3.2触摸事件接收顺序
    触摸点是否在按钮矩形内
    scrollview里container拖动显示问题
    cocos2dx 显示对象尺寸
    allocating an object of abstract class
    学习scorllview
    cocos2dx引用计数
    addchild 报错不能添加nil
    有用的宏
    一段SQL
  • 原文地址:https://www.cnblogs.com/rongye/p/9940546.html
Copyright © 2020-2023  润新知