会员
周边
众包
新闻
博问
闪存
赞助商
所有博客
当前博客
我的博客
我的园子
账号设置
简洁模式
...
退出登录
注册
登录
F
A man lost oh the way to far ...
博客园
首页
新随笔
联系
管理
订阅
上一页
1
2
3
4
下一页
2017年6月16日
Python装饰器 完善
摘要: 1 #author F 2 username = "123" 3 password = "321" 4 5 def login(cate): 6 def outerwraped(func): 7 def wrapped(*args, **kwargs): 8 user = input("Username").strip() 9 ...
阅读全文
posted @ 2017-06-16 09:44 Bird_getUpEarly
阅读(128)
评论(0)
推荐(0)
编辑
2017年6月15日
Python通用装饰器
摘要: 1 #author F 2 import time 3 4 5 def timer(func): 6 def deco(*args, **kwargs): #保证传递所有参数都能使用 7 start_time = time.time() 8 func(*args, **kwargs) 9 stop_time = tim...
阅读全文
posted @ 2017-06-15 17:26 Bird_getUpEarly
阅读(134)
评论(0)
推荐(0)
编辑
Python装饰器
摘要: 1 #author F 2 3 #装饰器: 本质是函数 为其他函数添加功能 文章发表过程->前后添加->运营添加->... 4 #已经上线 100个函数用到 需要修改 5 #装饰器原则: 1.不能修改被装饰函数的代码 6 # 2.不能修改被装饰的函数的调用方式 7 #也即: 装饰器对被装饰函数是透明的 对被装饰函数完全不影响 8 9 i...
阅读全文
posted @ 2017-06-15 16:14 Bird_getUpEarly
阅读(152)
评论(0)
推荐(0)
编辑
2017年6月14日
Python简单递归
摘要: 1 #author F 2 3 #递归 : 自己调用自己 4 #必须有一个明确的结束条件 5 #每次进入更深一层递归时 问题规模要比上一层小 6 #递归效率不高, 递归层次过多会导致栈溢出 函数的调用是通过栈来实现的 7 def calc(n): 8 print(n) 9 return calc(n+1) 10 11 # calc(0) 12 13 de...
阅读全文
posted @ 2017-06-14 11:21 Bird_getUpEarly
阅读(214)
评论(0)
推荐(0)
编辑
2017年6月13日
Python函数基本用法
摘要: 1 #author F 2 import time 3 #面向对象 : 类 --->class 4 #面向过程 : 过程-->def 5 #函数式编程 : 函数-->def 6 7 #定义函数 8 def func1(): 9 """testing""" 10 print("in the func1") 11 return 0 12 #定义过程...
阅读全文
posted @ 2017-06-13 18:41 Bird_getUpEarly
阅读(190)
评论(0)
推荐(0)
编辑
Python编码转换
摘要: 1 #author F 2 #字符编码 3 4 import sys 5 print(sys.getdefaultencoding()) #打印默认编码 6 ''' 7 #python2中编码转换 8 9 s = "你好" 10 s_to_unicode = s.decode("utf-8") 11 print(s_to_unicode) 12 s_to_gbk = s_t...
阅读全文
posted @ 2017-06-13 15:15 Bird_getUpEarly
阅读(122)
评论(0)
推荐(0)
编辑
Python 文件内容修改-循环+with语句
摘要: 1 #author F 2 3 #with语句 4 5 with open("test", "r", encoding="utf-8") as f: #with代码块执行完毕时会自动关闭并释放资源 6 for line in f: 7 print(line) 8 9 with open("test", "r", encoding="utf-8"...
阅读全文
posted @ 2017-06-13 11:27 Bird_getUpEarly
阅读(1879)
评论(0)
推荐(0)
编辑
Python文件操作
摘要: 1 #author F 2 3 import sys,time 4 5 6 f = open("file", "r", encoding="utf-8") 7 8 print(f.tell()) 9 print(f.readline().rstrip()) 10 print(f.read(5)) 11 print(f.tell()) 12 print(f.read())...
阅读全文
posted @ 2017-06-13 10:32 Bird_getUpEarly
阅读(166)
评论(0)
推荐(0)
编辑
2017年6月9日
Python文件基本操作
摘要: 1 #author F 2 3 # data = open("test.txt", encoding="utf-8").read() 4 # f = open("test.txt", 'r', encoding="utf-8") #文件句柄 r->读 5 # data = f.read() 6 # data2 = f.read() 7 # print(f) 8 # print...
阅读全文
posted @ 2017-06-09 17:27 Bird_getUpEarly
阅读(166)
评论(0)
推荐(0)
编辑
Python集合基本用法
摘要: 1 #author F 2 3 list_1 = [1, 4, 6, 8, 6, 34, 77] 4 list_1 = set(list_1) #列表转集合 集合和字典一样 都是无序的 5 print(list_1, type(list_1)) 6 7 list_2 = set([4, 5, 6, 98, 2, 5]) 8 print(list_1, list_2) 9 ...
阅读全文
posted @ 2017-06-09 15:54 Bird_getUpEarly
阅读(741)
评论(0)
推荐(0)
编辑
上一页
1
2
3
4
下一页
公告