2017年9月23日

python之hashlib模块

摘要: from hashlib import md5, sha512 # from _hashlib import HASH def main(): # md = md5() md = sha512() # print(type(md), md) md.update('zxl'.encode()) md.update('hhu'.encode()) ... 阅读全文

posted @ 2017-09-23 14:39 靖康耻 阅读(151) 评论(0) 推荐(0) 编辑

python之configparser模块

摘要: from configparser import ConfigParser def write(): cp = ConfigParser() cp['one'] = { 'aa': '111', 'bb': '222' } cp['two'] = dict( cc='zxl', dd='hhu' ... 阅读全文

posted @ 2017-09-23 13:01 靖康耻 阅读(124) 评论(0) 推荐(0) 编辑

2017年9月21日

Python之time模块

摘要: 前言: 环境:python解释器是windows平台3.6.1版本. Python中主要使用1.元组(struct_time对象) 2.格式化的时间字符串 3.时间戳 这三种形式表示时间.本文主要讲述利用time模块的内置函数进行三种形式互相转化. %y 两位数的年份表示(00-99) %Y 四位数 阅读全文

posted @ 2017-09-21 19:24 靖康耻 阅读(451) 评论(0) 推荐(0) 编辑

python之os模块

摘要: from os import * # makedirs('aaa/bbb') # mkdir('ccc') # mkdir('ccc/ddd')#必须ccc目录已经存在 # chdir('aaa/bbb') # print(getcwd()) # print(curdir) # print(pardir) # removedirs('aaa/bbb') # 目录不为空时会产生错误 # rmdi... 阅读全文

posted @ 2017-09-21 17:30 靖康耻 阅读(126) 评论(0) 推荐(0) 编辑

python之random模块

摘要: 输出:(结果是随机的,下面只是一次运行的结果,仅做参考) <class 'float'> 0.6281382442051219 <class 'int'> 64<class 'list'> [45, 2]<class 'int'> 2AZwq9 阅读全文

posted @ 2017-09-21 16:34 靖康耻 阅读(265) 评论(0) 推荐(0) 编辑

2017年9月20日

python generator(生成器)

摘要: send的用法: 输出: onetwothreefourfive 阅读全文

posted @ 2017-09-20 21:13 靖康耻 阅读(124) 评论(0) 推荐(0) 编辑

python 装饰器

摘要: 输出: start1start2code haha0.0end2end1hello__zxl 输出: 不打印日志start2(3, 4, 5, 6, 7)0.0end225 阅读全文

posted @ 2017-09-20 18:32 靖康耻 阅读(130) 评论(0) 推荐(0) 编辑

用reduce实现阶乘计算

摘要: 输出: 120 阅读全文

posted @ 2017-09-20 17:46 靖康耻 阅读(483) 评论(0) 推荐(0) 编辑

python实现裴波那契数列

摘要: 用生成器实现如下: 阅读全文

posted @ 2017-09-20 17:15 靖康耻 阅读(1026) 评论(0) 推荐(0) 编辑

python新增nonlocal关键字

摘要: def fa(a): b = 2 def fb(): nonlocal b print(b) return fbc = 2fa(22)()# python作用域:LEGB 阅读全文

posted @ 2017-09-20 16:16 靖康耻 阅读(171) 评论(0) 推荐(0) 编辑

导航