python的闭包的特点是返回的函数还引用了外层函数的局部变量,所以,要正确使用闭包,就要确保引用的局部变量在函数返回后不能变。如下:defcount():
fs=[]
foriinrange(1,4):
deflazy_count(j):
defcou():
returnj*j
returncou
r=lazy_count(i)
fs.append(r)
returnfs
f1,f2,..
分类:
编程语言 时间:
2015-09-16 01:04:11
阅读次数:
272
1.基本需求编写一个查询员工信息表的程序,实现如下功能:(1)让用户输入不小于3个字符查询员工信息(2)通过员工号或员工个人信息可以精确或模糊查询到员工信息(3)输出员工信息2.实现代码与注释首先提供员工信息的txt文件:xpleaf@xpleaf-machine:/mnt/hgfs/Python/day3$mo..
分类:
编程语言 时间:
2015-09-16 01:01:06
阅读次数:
251
1首先删除所有的外检约束--删除所有外键约束DECLARE c1 cursor forselect 'alter table ['+ object_name(parent_obj) + '] drop constraint ['+name+']; 'from sysobjectswhere xtyp...
分类:
数据库 时间:
2015-09-16 00:55:26
阅读次数:
280
--查询用户SELECT User, Password, Host FROM user;--创建一个用户,任意主机可以登录%,密码是123456CREATE USER 'palm'@'%' IDENTIFIED BY '123456';-- 给用户赋予所有权限GRANT ALL ON *.* TO ...
分类:
数据库 时间:
2015-09-16 00:53:43
阅读次数:
189
以下安装步骤基本来自官网,做个笔记以方便自己以后查看http://trac.ffmpeg.org/wiki/CompilationGuide1.安装依赖包[python]view plaincopyprint?yuminstallautoconfautomakegccgcc-c++gitlibtoo...
分类:
其他好文 时间:
2015-09-16 00:45:10
阅读次数:
258
使用vim编辑器,首先新建一个py文件:vimprint_filename.py1、读取指定目录下地所有文件和目录名print_filename.py#-** coding:utf-8 -*- //注释,提示使用支持Unicode编码的编辑器环境improt os //引用os 模块print...
分类:
编程语言 时间:
2015-09-16 00:41:23
阅读次数:
136
Problem:The API:int read4(char *buf)reads 4 characters at a time from a file.The return value is the actual number of characters read. For example, it...
分类:
其他好文 时间:
2015-09-16 00:39:34
阅读次数:
254
urlparse模块主要是把url拆分为6部分,并返回元组。并且可以把拆分后的部分再组成一个url。主要有函数有urljoin、urlsplit、urlunsplit、urlparse等。urlparse.urlparse(urlstring[, scheme[, allow_fragments.....
分类:
编程语言 时间:
2015-09-15 23:30:14
阅读次数:
263
首先声明这篇学习记录是基于python3的。 python3中,py文件中默认的文件编码就是unicode,不用像python2中那样加u,比如u'中文'。 不过在涉及路径时,比如C:\Users\Administrator\Desktop\StudyNote\Python,还是要加r。 ...
分类:
编程语言 时间:
2015-09-15 23:27:48
阅读次数:
361
表:studenthousecourse关系:student_course 多对多student house 多对一需求:查询房间1 的学生 都学习了什么课程 select s.s_name,c.c_name from student s left outer join student_cours....
分类:
数据库 时间:
2015-09-15 23:23:54
阅读次数:
291