注:random.random:随机取一个数值。 注:random.randint(范围,范围):随机取范围内的值。 注:random.randrange(范围,范围):随机取值如1-3就不包含3,与range相同。 注:random.choice(“[]”):在一组列表,字符串,或元组,中随机取值 ...
分类:
编程语言 时间:
2017-11-05 13:17:25
阅读次数:
177
import random print(random.random()) # (0,1)----float 大于0且小于1之间的小数 print(random.randint(1, 3)) # [1,3] 大于等于1且小于等于3之间的整数 print(random.randrange(1, 3)) ... ...
分类:
其他好文 时间:
2017-11-02 16:58:03
阅读次数:
201
product_list = [('iphone',5800),('iwatch',2400),('book',80),('apple',50)] #创建列表库shoppinglist = [] #定义购物车的列表salary = input("input your salary:")if sala ...
分类:
编程语言 时间:
2017-11-01 12:15:39
阅读次数:
279
经典语句-中英对照 Love your parents. We are too busy growing up yet we forget that they are already growing old——多关心一下自己的父母吧,我们总忙着自己成长,却忘了他们也在变老。 The moment y ...
分类:
其他好文 时间:
2017-10-31 11:15:22
阅读次数:
192
可以使用random.choice(USER-AGENT) 进行随机获取一个UA! ...
分类:
其他好文 时间:
2017-10-30 11:39:13
阅读次数:
2649
1.list页面:筛选功能优化,显示choices,传condition过滤筛选项 list_filter = [ # sites.FilterOption("name",False,lambda x:x.name,lambda x:x.name),#这种配置无意义 sites.FilterOpti ...
分类:
其他好文 时间:
2017-10-28 19:02:31
阅读次数:
137
需求:1.启动程序后,让用户输入工资,然后打印商品列表;2.允许用户根据商品编号购买商品;3.用户选择商品后,检测余额是否足够,够就直接扣款,不够就提醒;4.可随时退出,退出时打印已购买的商品列表。# Author: Ewan Wangshopping_list = []goods_list = [ ...
分类:
其他好文 时间:
2017-10-25 23:29:53
阅读次数:
98
我认为增加中奖的概率 不换1/3 换2/3 form random import* t=10000 first=0 change=0 for i in range (t): a="羊1","羊2","车" car=choice(a) my=choice(a) if car=my first=n+=1 ...
分类:
其他好文 时间:
2017-10-22 00:32:16
阅读次数:
125
异常处理:异常处理要用到try,except,else,finally等eg1:dic={ "id":1, "name":"houning", "sex":"nv"}choice=input('请输入您要查看的属性:')try: #异常处理要用到try print(dic[choice]) #如果代 ...
分类:
编程语言 时间:
2017-10-18 23:06:35
阅读次数:
216
product_list=[
(,),
(,),
(,),
(,),
(,),
(,),
]
shopping_list=[]salary=()salary.isdigit():salary=(salary)
:
index,item(product_list):(index,item)
user_choice=()
user_choice.isdigit():user_choice=(user_choice)user_choice<(product_list)user_choice>=:p_it..
分类:
编程语言 时间:
2017-10-18 19:42:04
阅读次数:
130