闻峥

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::

01 2019 档案

摘要:"^\d+$" //非负整数(正整数 + 0) "^[0-9]*[1-9][0-9]*$" //正整数 "^((-\d+)|(0+))$" //非正整数(负整数 + 0) "^-[0-9]*[1-9][0-9]*$" //负整数 "^-?\d+$" //整数 "^\d+(\.\d+)?$" //非负 阅读全文
posted @ 2019-01-28 11:59 闻峥 阅读(2719) 评论(0) 推荐(0)

摘要:>>> ls1 = ['a', 1, 'b', 2] >>> ls2 = [str(i) for i in ls1] >>> ls2 ['a', '1', 'b', '2'] >>> ls3 = ''.join(ls2) >>> ls3 'a1b2' 阅读全文
posted @ 2019-01-28 11:56 闻峥 阅读(11202) 评论(0) 推荐(0)

摘要:from functools import reduce num = 10 print(reduce(lambda x, y: x * y, range(1, num + 1))) 阅读全文
posted @ 2019-01-26 15:50 闻峥 阅读(771) 评论(0) 推荐(0)

摘要:python中没有其它语言中的三元表达式,如: python中的类似写法为: a>b成立,则h等于变量1 a>b不成立,则h等于变量2 阅读全文
posted @ 2019-01-26 15:25 闻峥 阅读(493) 评论(0) 推荐(0)

摘要:OperationResultTrans x in s True if an item of s is equal to x, else False x值是否在s列表中 x not in s False if an item of s is equal to x, else True x值是否不在s列表中 s + t the concatenation of s and ... 阅读全文
posted @ 2019-01-16 17:36 闻峥 阅读(258) 评论(0) 推荐(0)

摘要:小数问题是计算机编程中大部分语言都会遇到的问题,尤其是在内容中涉及到评分、金额计算等等,本人一般在解决需求中固定小数位的数字计算时,都会先将其放大整10的倍数至整数,然后计算、存储,只有在显示的时候再将其缩小至所需的精度:如人民币的计算和存储都是以分为单位。 在学习python的时候同样也会有这样的 阅读全文
posted @ 2019-01-16 17:03 闻峥 阅读(2429) 评论(0) 推荐(0)