摘要:
1. 定义模块:用来从逻辑上组织python代码(变量,函数,类,逻辑:实现一个功能),本质就是.py结尾的python文件(文件名:test.py。对应的模块名:test) 包:包的本质是一个目录(带有一个叫__init__.py文件),包是用来从逻辑上组织模块 2.导入方法:import mod 阅读全文
摘要:
这是网页源代码 <html xmlns="http://www.w3.org/1999/xhtml"> <head> <script type="text/javascript"> document.domain = 'kuwo.cn'; function killerr() { return tr 阅读全文
摘要:
# 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... 阅读全文
摘要:
#!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 ... 阅读全文
摘要:
def eat(): print('我吃什么:') a=yield '馒头' print(a) b = yield '大饼' print(b) c=yield'韭菜盒子' print(c) print('程序结束') yield 'GEME OVER' gen=eat() #表达 gen是一个生成... 阅读全文
摘要:
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 阅读全文
摘要:
多个装饰器装饰一个函数 简单的装饰器 test1=door(test1) 带参函数 阅读全文
摘要:
import sys ,time for i in range(4): sys.stdout.write('*') sys.stdout.flush() print(i,end='') time.sleep(1) 阅读全文
摘要:
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 阅读全文
摘要:
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... 阅读全文