上一页 1 ··· 3 4 5 6 7 8 下一页
摘要: 类的成员修饰符 一般情况的类成员为共有成员 如: 而私有成员是如下情况在字段前加两个下划线以及其调用方式创建一个新的方法 且无法直接访问,这能间接访问 上诉为字段的私有成员,方法的私有成员以及父类私有成员的调用如下 阅读全文
posted @ 2020-02-06 17:53 ComeIntoBud 阅读(223) 评论(0) 推荐(0) 编辑
摘要: 这是我自己做的一张关于类的基础知识点 阅读全文
posted @ 2020-02-02 17:28 ComeIntoBud 阅读(172) 评论(0) 推荐(0) 编辑
摘要: 首先是引入json 和 pickle 的原因是 普通的方法支持的数据类型太少 局限性大 比如下面的例子 dit = {'name':'deng1mei','age':'26','sex':'girl'} #创建一个字典dit = str(dit) #将字典字符串化 以方便写入文件# f= open 阅读全文
posted @ 2019-12-20 14:54 ComeIntoBud 阅读(176) 评论(0) 推荐(0) 编辑
摘要: st = 'hello ketty ##$ \*'print(st.count('t'))# 输出‘t’的个数print(st.capitalize()) #Hello ketty 将首字母大写print(st.center(30,'-')) # hello ketty 将st放在30个'_'的中间 阅读全文
posted @ 2019-12-16 21:49 ComeIntoBud 阅读(494) 评论(0) 推荐(0) 编辑
摘要: import configparser #配置文件config = configparser.ConfigParser()config["DEFAULT"] = {'ServerAliveInterval': '45','Compression': 'yes','CompressionLevel': 阅读全文
posted @ 2019-12-16 20:51 ComeIntoBud 阅读(115) 评论(0) 推荐(0) 编辑
摘要: 代码如下 1 import re 2 def form_at(string): 3 string = string.replace('++','+') 4 string = string.replace('-+','-') 5 string = string.replace('+-','-') 6 阅读全文
posted @ 2019-12-14 22:47 ComeIntoBud 阅读(285) 评论(0) 推荐(0) 编辑
摘要: import re s = 'hello world'a = s.find('h')print(a)p = s.replace('l', 'xx')print(p)b = s.split('w')print(b) ###############################元字符 1:‘ . ’通 阅读全文
posted @ 2019-12-06 19:13 ComeIntoBud 阅读(612) 评论(0) 推荐(0) 编辑
摘要: import hashlib #多用于加密a=hashlib.md5()print(a) #<md5 HASH object @ 0x00000000021CCF90>a.update('i love you dengmei'.encode('utf8'))print(a.hexdigest()) 阅读全文
posted @ 2019-11-25 22:31 ComeIntoBud 阅读(190) 评论(0) 推荐(0) 编辑
摘要: import sys #与python解释器 交互print(sys.argv) #是一个列表 解释器执行文件名后面可以增加字符串 以列表元素形式添加进去def foo(): print('ok')def voo(): print('gggg boon!')if sys.argv[1]=='deng 阅读全文
posted @ 2019-11-25 21:59 ComeIntoBud 阅读(330) 评论(0) 推荐(0) 编辑
摘要: import osprint(os.getcwd()) #拿到当前文件的目录os.chdir(r'E:\pycharm 5.3 wenjian weizhi ')#改变当前脚本的工作目录 'r'表示原生字符串 表示所有的字符都是单纯的字符串无其他特殊功能或含义如'/n'print(os.getcwd 阅读全文
posted @ 2019-11-20 20:32 ComeIntoBud 阅读(190) 评论(0) 推荐(0) 编辑
摘要: import timeprint(help(time))print(time.time())#时间戳 1573991312.5361328print(time.perf_counter())#计算CPU的执行时间结构化时间:print(time.gmtime())#UTC时间 世界标准时间time. 阅读全文
posted @ 2019-11-17 21:58 ComeIntoBud 阅读(160) 评论(0) 推荐(0) 编辑
摘要: #生成器都是迭代器 ,迭代器不一定是生成器#list,tuple,sict,string:Iterable(可迭代对象)#什么是迭代器?#满足两个条件:1有iter方法 2有next方法a = [1,2,3,4,]b= a.__iter__()print(b) #<list_iterator obj 阅读全文
posted @ 2019-11-15 22:04 ComeIntoBud 阅读(142) 评论(0) 推荐(0) 编辑
摘要: import timedef custumer(name): print('%s 准备吃饺子了'%name) while True: curry = yield print('饺子%s来了 ,被%s吃了'%(curry,name))def produce(na_me): c =custumer('A 阅读全文
posted @ 2019-11-15 21:04 ComeIntoBud 阅读(115) 评论(0) 推荐(0) 编辑
摘要: 生成式 def f(n): return n**3a = [f(x) for x in range(10)] 这就是个简单的生成式print(a) #[0, 1, 8, 27, 64, 125, 216, 343, 512, 729]print(type(a))#<class 'list'>b = 阅读全文
posted @ 2019-11-13 22:02 ComeIntoBud 阅读(153) 评论(0) 推荐(0) 编辑
摘要: 直接举例子说吧! def test(): print('look look') #这是个普通函数接下来就是个简单的装饰器 (其实装饰器的意义就是:给其它函数增加功能用的) import time #调用时间模块def show_time(): def inner(f): start = time.t 阅读全文
posted @ 2019-11-11 21:48 ComeIntoBud 阅读(122) 评论(0) 推荐(0) 编辑
上一页 1 ··· 3 4 5 6 7 8 下一页