2018年12月21日

摘要: isinstance() 判断某个对象是不是某个类的实例 issubclass() 是不是字类 class Student: def __init__(self,name,sex,age): self.name = name self.age = age self.sex = sex def stu 阅读全文
posted @ 2018-12-21 15:30 BestSkye 阅读(105) 评论(0) 推荐(0) 编辑

2018年12月13日

摘要: 在计算机创建一个人类对象 要得到对象,必须先告诉计算机,这个对象具备什么特征和行为,所以需要先定义类 类名要按照大驼峰的方式来书写 ThisIsPerson 每个单词首字母大写 class People 在类中描述对象的特征和行为 class Person name='李四' sex=‘male’ 阅读全文
posted @ 2018-12-13 18:52 BestSkye 阅读(156) 评论(0) 推荐(0) 编辑

2018年12月6日

摘要: import hashlib m=hashlib.md5() m.update('你好'.encode('utf8')) m.update('hello'.encoding('utf8')) print(m.hexdigest()) m=hashlib.sha512() m.update('你好'. 阅读全文
posted @ 2018-12-06 16:34 BestSkye 阅读(132) 评论(0) 推荐(0) 编辑
 
摘要: 常用的匹配模式: 正则表达式是根据一定的规则把字符串匹配处理 import re # msg='1-2*(60+((-40.35)/5)-(-4*3))' # print(re.findall('\D?(-?\d+\.?\d*)',msg)) print(re.findall('skye','sky 阅读全文
posted @ 2018-12-06 16:17 BestSkye 阅读(103) 评论(0) 推荐(0) 编辑

2018年12月4日

摘要: dic={'k1':True,'k2':10,'k3':'egon','k4':'你好啊',} ###json import json ##序列化 dic_json=json.dumps(dic) print(dic_json,type(dic_json)) ##持久化 with open('a.j 阅读全文
posted @ 2018-12-04 16:17 BestSkye 阅读(192) 评论(0) 推荐(0) 编辑

2018年11月28日

摘要: 函数对象 在面向对象编程中 一切皆对象 具体的体现 1.函数可以被引用 2.函数可以作为函数的参数 3.函数可以作为函数的返回值 4.可以被存储到容器类型中 2.函数嵌套 1.嵌套调用 在一个函数中调用了另一个函数 2.嵌套定义 在一个函数中定义了另一个函数 定义在函数内的函数 只能函数内使用 外界 阅读全文
posted @ 2018-11-28 19:24 BestSkye 阅读(162) 评论(0) 推荐(0) 编辑

2018年11月27日

摘要: 一 函数的参数分为两大类: 1.形参:在定义函数时括号内指定的参数(变量名),称之为形参 2.实参:在调用函数时括号内传入的值(变量值),称之为实参 阅读全文
posted @ 2018-11-27 16:11 BestSkye 阅读(114) 评论(0) 推荐(0) 编辑

2018年11月26日

摘要: x='上' #unicode的二进制 编码encode >gbk格式的二进制 res=x.encode('gbk') # res=x.encode('utf-8') print(res,type(res)) #unicode的二进制< 解码decode gbk格式的二进制 m=res.decode( 阅读全文
posted @ 2018-11-26 18:33 BestSkye 阅读(125) 评论(0) 推荐(0) 编辑

2018年11月23日

摘要: 以下两个场景下涉及到字符编码的问题: !!!总结非常重要的两点!!! unicode >encode >utf-8 utf-8 >decode >unicode 阅读全文
posted @ 2018-11-23 19:19 BestSkye 阅读(120) 评论(0) 推荐(0) 编辑

2018年11月21日

摘要: 1.整形int 定义方式:age=10 #age=int(10) *十进制转换 print(bin(13))#转成2进制 print(oct(13))#转成8进制 print(hex(13))#转成16进制 2.浮点型float 3定义方式: salary=10.1# salary=float(10 阅读全文
posted @ 2018-11-21 16:13 BestSkye 阅读(195) 评论(0) 推荐(0) 编辑