2018年7月20日

装饰器案例2

摘要: #!\usr\bin\env\python # -*- coding:utf-8 -*9 import time user,passwd='alex','abc123' #写定账户密码 def auth(auth_type): #定义装饰器函数 print("auth func :",auth_ty 阅读全文

posted @ 2018-07-20 11:47 凛冬08 阅读(92) 评论(0) 推荐(0) 编辑

装饰器案例1:

摘要: #!\usr\bin\env\python # -*- coding:utf-8 -*9 import time def timer(func): #定义装饰器函数 def deco(*args,**kwargs): #定义嵌套函数 start_time=time.time() func(*args 阅读全文

posted @ 2018-07-20 11:11 凛冬08 阅读(76) 评论(0) 推荐(0) 编辑

2018年7月13日

生病停了几天时间-装饰器

摘要: #!\usr\bin\env\python # -*- coding:utf-8 -*9 import time #调用一个time模块 def timer(func): #装饰器timer,装饰器的构成即为:高阶函数+嵌套函数 def deco(*arg,**kwarg): #嵌套函数 strat 阅读全文

posted @ 2018-07-13 10:12 凛冬08 阅读(91) 评论(0) 推荐(0) 编辑

2018年7月4日

如何在函数中修改局部变量

摘要: #!\usr\bin\env\python # -*- coding:utf -8 -*9 school ="0ldboy edu." #定义全局变量 def change_name(name): global school #利用global修改全局变量 school = "Mage Linux" 阅读全文

posted @ 2018-07-04 11:24 凛冬08 阅读(774) 评论(0) 推荐(0) 编辑

2018年7月3日

函数详解

摘要: def test(*args): print(args) test(1,2,3,4,5,5) test(*[1,2,4,5,5]) #传进的有参数都会被args变量收集,根据传进参数的位置合并为一个元组(tuple),args是元组类型,以元组的形式输出结果 def test2(**kwargs): 阅读全文

posted @ 2018-07-03 20:34 凛冬08 阅读(116) 评论(0) 推荐(0) 编辑

定义函数和过程

摘要: #!\usr\bin\env\python #-*- coding:utf -8 -*9 #定义函数 def func1(): "书写函数声明" print('in the func1') return 0 #定义过程 def func2(): print('in the func2') #调用函数 阅读全文

posted @ 2018-07-03 19:55 凛冬08 阅读(144) 评论(0) 推荐(0) 编辑

2018年6月28日

字符转码

摘要: #!\usr\bin\env\python import sys f = open("yest2",'r',encoding="utf-8") f_new= open("yest2.bak",'w',encoding="utf-8") find_str=sys.argv[1] #旧字符 replac 阅读全文

posted @ 2018-06-28 16:53 凛冬08 阅读(84) 评论(0) 推荐(0) 编辑

文件操作

摘要: #!\usr\bin\env\python # _*_ coding:utf-8 -*9 #文件打开 '''data = open("yest",encoding="utf-8").read() f = open("yest2","a",encoding="utf-8") f.write("afoa 阅读全文

posted @ 2018-06-28 11:31 凛冬08 阅读(95) 评论(0) 推荐(0) 编辑

2018年6月11日

三级菜单优化程序

摘要: #!\usr\bin\env\python # -*- coding:utf - 8 -*9 data = 阅读全文

posted @ 2018-06-11 14:52 凛冬08 阅读(88) 评论(0) 推荐(0) 编辑

2018年4月19日

元组的功能

摘要: #!\usr\bin\env\python# -*- coding:utf - 8 -*9info = { 'stu1101':"TengLan Wu", 'stu1102':"LongZe Luola", 'stu1103':"XiaoZe Maliya", }#增加info ["stu1104" 阅读全文

posted @ 2018-04-19 14:10 凛冬08 阅读(133) 评论(0) 推荐(0) 编辑

导航