
python 学习笔记
知性肥宅在线写bug
这个作者很懒,什么都没留下…
展开
-
python 类的使用
用关键词 class 定义一个类如果没有指定父类,则默认object类 class Human(object) pass类属性class Human(object): taisheng=True类属性为类的属性,与类绑定,所有该类都有这种属性。实例属性class Human(object): def __init__(self,name) sel...原创 2018-03-04 13:06:53 · 266 阅读 · 0 评论 -
python 模块
正常工程中,代码需要分模块来进行存储。例如在hello.py文件中:def print_hello(): print("hello")在另一个文件main.py中使用hello.py 中的print_hello函数可以用import直接引用hello文件:import hellohello.print_hello()也可以使用from来引用,from只能一次引用一个函数,然后直接使用函数:f...原创 2018-03-04 14:58:47 · 244 阅读 · 0 评论 -
正则表达式的语法
import rem=re.findall(".","aa\nbbcc")print(m) 此处输出['a', 'a', 'a', 'b', 'b', 'c', 'c'] "."表示输出所有非换行符的字符转义字符m=re.findall("\.","a.c")print(m) "\."利用\作为转义字符,输出所有".原创 2018-03-29 23:02:43 · 660 阅读 · 0 评论