随笔分类 -  python

python学习
摘要:python 常用开发技巧 列表推导式 >>> chars = [ c for c in 'python' ] >>> chars ['p', 'y', 't', 'h', 'o', 'n'] 字典推导式 >>> dict1 = {'a': 1, 'b': 2, 'c': 3, 'd': 4, 'e 阅读全文
posted @ 2020-11-12 20:03 有为则无心 阅读(70) 评论(0) 推荐(0)
摘要:python 动态调用方法示例 eval() 函数用来执行一个字符串表达式,并返回表达式的值。 def response(request, def_name): request_method = request.method try: if def_name in ['product_update' 阅读全文
posted @ 2020-10-29 11:37 有为则无心 阅读(66) 评论(0) 推荐(0)
摘要:python 等概率生成随机数方法 ran_list = ['0','1','2','3','4','5','6','7','8','9'] random.shuffle(ran_list) rst = 'N'+(''.join(list(ran_list[:7]))) 阅读全文
posted @ 2020-10-29 10:58 有为则无心 阅读(284) 评论(0) 推荐(0)