摘要:
这是一种通过遍历来实现查看磁盘大小的功能
阅读全文
posted @ 2018-06-01 11:12
python我的最爱
阅读(205)
推荐(0)
摘要:
socket 客户端 import socket 1.client = socket.socket() # socket.TCP/IP 选择连接的类型,默认为本地连接 2.client.connect(('localhost', 6000)) # connect(a.ip, a.port) a.ip
阅读全文
posted @ 2018-05-29 11:25
python我的最爱
阅读(216)
推荐(0)
摘要:
异常处理中常见的语法 try 尝试运行 except 接受错误 else 正确时执行 finally 不管对错都执行这一步 举例
阅读全文
posted @ 2018-05-28 22:48
python我的最爱
阅读(203)
推荐(0)
摘要:
当用户输入字符串时,不能够用来运行程序 1.使用 hasattr 找出输入的字符串是否在程序内 2.使用 getattr 返回找出字符串对应的函数的内存地址或者变量 3. 使用setattr 添加新的函数,或者改变已有的程序的实例变量或类变量
阅读全文
posted @ 2018-05-28 22:34
python我的最爱
阅读(178)
推荐(0)
posted @ 2018-05-28 21:16
python我的最爱
阅读(181)
推荐(0)
摘要:
class Foo(object): def __init__(self): self.data = {} def __getitem__(self, key): print('__getitem__', key) return self.data.get(key) #返回查找的结果,如果没有返回n
阅读全文
posted @ 2018-05-28 20:56
python我的最爱
阅读(222)
推荐(0)
摘要:
1.(静态方法) class Dog(object): def __init__(self, name): self.name = name @staticmethod def name(obj): print('%s is name'%obj) Dog.name('ronghua') @stati
阅读全文
posted @ 2018-05-28 19:49
python我的最爱
阅读(1189)
推荐(0)
摘要:
class 的三大特性 封装:内部调用对于外部用户是透明的 继承: 在分类里的属性,方法被自动继承 多态:调用这个功能,可以使多个类同时执行 r1 = Role(r1, 'Alex', 'Police', '15000') #实际上把r1赋给了self self.name = 'Alex' # r1
阅读全文
posted @ 2018-05-26 17:28
python我的最爱
阅读(1694)
推荐(0)
摘要:
import re # re 存在5种使用方式 #1. macth #2.search #3.findall #4.split #5 sub re.match('^chen', 'chenhua123').group() #加.group() 查看查找的内容 re.search('chen+a$',
阅读全文
posted @ 2018-05-23 20:33
python我的最爱
阅读(212)
推荐(0)
摘要:
import hashlib #hashilib 模块 m = hashlib.md5() m.update('hello 天王盖地虎'.encode(encoding = 'utf-8)) m.hexdigest() # 显示密码 m = hashlib.sha256() m.update(b'1
阅读全文
posted @ 2018-05-23 17:07
python我的最爱
阅读(159)
推荐(0)