摘要: 1. 定义模块:用来从逻辑上组织python代码(变量,函数,类,逻辑:实现一个功能),本质就是.py结尾的python文件(文件名:test.py。对应的模块名:test) 包:包的本质是一个目录(带有一个叫__init__.py文件),包是用来从逻辑上组织模块 2.导入方法:import mod 阅读全文
posted @ 2018-06-27 10:04 没有永远的小白 阅读(100) 评论(0) 推荐(0) 编辑
摘要: 这是网页源代码 <html xmlns="http://www.w3.org/1999/xhtml"> <head> <script type="text/javascript"> document.domain = 'kuwo.cn'; function killerr() { return tr 阅读全文
posted @ 2018-06-26 07:57 没有永远的小白 阅读(119) 评论(0) 推荐(0) 编辑
摘要: # import bs4 # import requests # hml=requests.get('http://yinyue.kuwo.cn/billboard_%E9%85%B7%E6%88%91%E7%83%AD%E6%AD%8C%E6%A6%9C.htm').text # soup=bs4.BeautifulSoup(hml) # head=soup.head # print(head... 阅读全文
posted @ 2018-06-25 19:29 没有永远的小白 阅读(128) 评论(0) 推荐(0) 编辑
摘要: #!Usr/bin/env python # -*- coding:utf-8 -*- # Author:Alex Li html = """ The Dormouse's story The Dormouse's story Once upon a time there were three little sisters; and their names were , Lacie and ... 阅读全文
posted @ 2018-06-23 23:59 没有永远的小白 阅读(93) 评论(0) 推荐(0) 编辑
摘要: def eat(): print('我吃什么:') a=yield '馒头' print(a) b = yield '大饼' print(b) c=yield'韭菜盒子' print(c) print('程序结束') yield 'GEME OVER' gen=eat() #表达 gen是一个生成... 阅读全文
posted @ 2018-06-20 22:22 没有永远的小白 阅读(45) 评论(0) 推荐(0) 编辑
摘要: import time def test(name): print('\033[31;m%s已经准备好了,test:\033[0m'%name) while True: baozi=yield print('\033[31;m第%s包子来了,%s吃了\033[0m'%(baozi,name)) de 阅读全文
posted @ 2018-06-19 12:01 没有永远的小白 阅读(78) 评论(0) 推荐(0) 编辑
摘要: 多个装饰器装饰一个函数 简单的装饰器 test1=door(test1) 带参函数 阅读全文
posted @ 2018-06-17 18:23 没有永远的小白 阅读(119) 评论(0) 推荐(0) 编辑
摘要: import sys ,time for i in range(4): sys.stdout.write('*') sys.stdout.flush() print(i,end='') time.sleep(1) 阅读全文
posted @ 2018-06-16 11:36 没有永远的小白 阅读(123) 评论(0) 推荐(0) 编辑
摘要: a={'a':{'b':'oo'},'c':{'d':'袁珂'}}#del a['a']a.pop('a') #标准姿势print(a.get('c'))print(a.get('a'))print(a.setdefault('f','逯晓华'))print(a['f'])print(a.setde 阅读全文
posted @ 2018-06-15 22:18 没有永远的小白 阅读(108) 评论(0) 推荐(0) 编辑
摘要: file=open('yesteerday','r',encoding='utf-8') file_new=open('yesteerday1','w',encoding='utf-8') for line in file: if "逯晓华" in line: line=line.replace('逯晓华','hello 逯晓华') time_import='%Y... 阅读全文
posted @ 2018-06-15 10:53 没有永远的小白 阅读(79) 评论(0) 推荐(0) 编辑