摘要: 网上看视频时看到的简易购物车要求,先输入拥有的金额,出现供选择的货物列表,输入想要购买的货物编号,最后打印出已购物品清单和余额。fruit_list=[ ('cherry',20), ('apple',8), ('pear',5), ('banana',3), ('strawberry',12)]b 阅读全文
posted @ 2020-05-02 22:32 逝水无痕L 阅读(196) 评论(0) 推荐(0)
摘要: Python中的 isdigit() 是用于检测字符串是否只由数字组成,是则返回Ture,否则返回Flase isdigit()方法语法:str.isdigit() 注:当str是小数时返回Flase 例如: 运行 print(int(1.9) ) # 返回1a=input('输入1.9') # 当 阅读全文
posted @ 2020-05-02 01:44 逝水无痕L 阅读(2134) 评论(0) 推荐(0)
摘要: python中的int()函数 int(x, [base]) 默认base缺省值为10,也就是说不指定base的值时,函数将x按十进制处理 x 可以是数字或字符串,但是base被赋值后 x 的值只能是字符串 int(x):当x是数字时,int(x)就是x向0的方向取最大的整数。 例如: print( 阅读全文
posted @ 2020-05-02 01:00 逝水无痕L 阅读(1033) 评论(0) 推荐(0)