import random
#随机整数
import string
print(random.randint(0,99))
#随机选取0到100间的偶数
print(random.randrange(0, 101, 2))
#随机浮点数
print(random.random())
print(random.uniform(1, 10))
#随机字符
print(random.choice('abcdefg%^*f'))
#多个字符中选取特定数量的字符
print(random.sample('abcdefghij',3))
#多个字符中选取特定数量的字符组成新字符串
# print(string.join(random.sample(['a','b','c','d','e','f','g','h','i','j'], 3)).replace(" ",""))
#随机选取字符串
print(random.choice ( ['apple', 'pear', 'peach', 'orange', 'lemon'] ))
#洗牌
items = [1, 2, 3, 4, 5, 6]
random.shuffle(items)
print("洗牌:", items)
#从指定序列中随机获取k个元素作为一个片段返回,不会改变原有序列
list = []
list = random.sample(items,2)
print(list)
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有