摘要: # s2 = s.lower() # 小写 所有的单词字母小写# print(s2) #s = "al1ex is a gay and Wu傻sir is A gay too"# s1 = s.capitalize() # 把首字母变成大写# print(s1) # s3 = s.upper() # 阅读全文
posted @ 2018-09-21 21:05 学习python1234 阅读(216) 评论(0) 推荐(0) 编辑
摘要: 服务端: import socket sk = socket.socket() sk.connect(('127.0.0.1',8899)) while 1: name = input(">>>>:") sk.send(name.encode('utf-8')) # 字节 response = sk 阅读全文
posted @ 2018-09-05 15:41 学习python1234 阅读(111) 评论(0) 推荐(0) 编辑
摘要: import struct res=struct.pack("i","") print(res) print(len(res)) obj=struct.unpack("i",res) print(obj[0]) 阅读全文
posted @ 2018-09-04 18:01 学习python1234 阅读(93) 评论(0) 推荐(0) 编辑
摘要: c3算法:用来判断多个类之间有继承关系时怎么辨别他们的执行顺序 例子: 1 class A(object): 2 pass 3 4 class B(A): 5 pass 6 7 class C(B): 8 pass 9 10 class D(object): 11 pass 12 13 class 阅读全文
posted @ 2018-09-03 15:41 学习python1234 阅读(242) 评论(0) 推荐(0) 编辑
摘要: 约束:class BaseMessage(object): def send(self,x1): """ 必须继承BaseMessage,然后其中必须编写send方法。用于完成具体业务逻辑。 """ raise NotImplementedError(".send() 必须被重写.")class E 阅读全文
posted @ 2018-08-31 17:21 学习python1234 阅读(111) 评论(0) 推荐(0) 编辑
摘要: class Foo(object): def __init__(self,name,age): self.name = name self.age = age def func(self): pass def __iter__(self): # return iter([11,22,33,44,55 阅读全文
posted @ 2018-08-30 16:12 学习python1234 阅读(122) 评论(0) 推荐(0) 编辑
摘要: 1. 类名() 自动执行 __init__# obj = Foo(1,2)# 2. 对象() 自动执行 __call__# ret = obj(6,4,2,k1=456)# 3. 对象['xx'] 自动执行 __getitem__# ret = obj['yu']# print(ret)# 4. 对 阅读全文
posted @ 2018-08-29 15:52 学习python1234 阅读(165) 评论(0) 推荐(0) 编辑
摘要: 1成员 分三类: 变量 :实质变量和类变量 实质变量(字段) 共有实质变量 私有实质变量 类变量(静态字段) 共有类变量(静态字段) 私有类变量(静态字段) 2嵌套 阅读全文
posted @ 2018-08-28 16:45 学习python1234 阅读(91) 评论(0) 推荐(0) 编辑
摘要: #如何使用 from import# 需要从一个文件中使用哪个名字,就把这个名字导入进来# from my_module import name# from import的过程中仍然执行了这个被导入的文件# from my_module import read1# import谁就只能用谁# rea 阅读全文
posted @ 2018-08-23 20:25 学习python1234 阅读(105) 评论(0) 推荐(0) 编辑
摘要: 爬虫小例子: ] import re from urllib.request import urlopen def getPage(url): # 获取网页的字符串 response = urlopen(url) return response.read().decode('utf-8') def 阅读全文
posted @ 2018-08-17 15:26 学习python1234 阅读(100) 评论(0) 推荐(0) 编辑
levels of contents