`
文章列表

python小技巧

1 def f(a, L=[]): L.append(a) return L print(f(1)) print(f(2)) print(f(3)) ''' 设想的结果 [1] [2] [3] 打印结果 [1] [1, 2] [1, 2, 3] ''' #改成这样 def f(a, L=None): if L==None: L=[] L.append(a) return L print(f(1)) print(f(2)) print(f(3))   2 for循环 ...
win7 Git Bash     照着教程上的方法 $ git remote add origin git@github.com:wzgdavid/learn.git $ git push -u origin master    不行啊,那去github上换个名字先建一个helloDjango,然后回Bash,再添加。打入命令,它说已经存在,既然存在我应该就能 ...
document中可以内嵌document, document中也可以有数组, 如果document的数组中是document又是什么情况,   例如有个school的collection有如下的document { _id: 1, zipcode: "63109", students: [ { name: "john", school: 102, age: 10 }, { name: "jess", school: 102, age: 11 }, ...
在MongoDB中,一条数据称做document  embedded document 有这样一条insert语句   db.users.insert( {name:"Luck" address:{country:"China", city:"SH" } } ) 其中address就是一个embedded document,也就是说某个字段是一个document的情况 这样的结构,想一address中的字段作为查询条件,如下 db.users.find( ...

MongoDB查询基础

insert MongoDB中的数据是存在collection中的,类似表。collection中一条数据就是一个document。而collection存在db中。 比如要在一个名叫mydb的DB中,一个名叫users的collection中插入一条数据, 这是两条命令。   use mydb db.users.insert({ ...
下载好mongoDB之后,在mongoDB目录新建一个data目录,然后运行mongod.exe,例如 目录是E:\MongoDB,则 > e:\mongodb\bin\mongod -dbpath e:\mongodb\data 作用是指定一个mongodb的运行环境   浏览器中登入http://localhost:27017/   查看是否启动成功   然后另起一个命令行,运行mongo.exe,(> e:\mongodb\bin\mongo)或者直接双击它, 注意先是mongod.exe然后是mongo.exe  正确关闭mongodb服务器的方法 1 ...
操作系统: windows 7 git version 1.8.3.msysgit.0   git init git add . 系统出现如下错误:warning: LF will be replaced by CRLF   原因分析: CRLF -- Carriage-Return Line-Feed 回车换行 就是回车(CR, ASCII 13, \r) 换行(LF, ASCII 10, \n)。 这两个ACSII字符不会在屏幕有任何输出,但在Windows中广泛使用来标识一行的结束。而在Linux/UNIX系统中只有换行符。 也就是说在windows中的换行符为 C ...
http://www.liaoxuefeng.com/wiki/001374738125095c955c1e6d8bb493182103fac9270762a000/00138681965108490cb4c13182e472f8d87830f13be6e88000 通过列表生成式,我们可以直接创建一个列表。但是,受到内存限制,列表容量肯定是有限的。而且,创建一个包含100万个元素的列表,不仅占用很大的存储空间,如果我们仅仅需要访问前面几个元素,那后面绝大多数元素占用的空间都白白浪费了。 所以,如果列表元素可以按照某种算法推算出来,那我们是否可以在循环的过程中不断推算出后续的元素呢?这样就 ...

Python列表生成式

列表生成式即是Python内置的非常简单却强大的可以用来创建list的生成式。 举个例子,要生成list [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]可以用range(1, 11): 即使稍复杂点的也可以不用写循环赋值了 list=[1,2,3,4,5] #每一项都是list的两倍 list2=[2*x for x in list] print(list2)#[2,4,6,8,10] #list中值为偶数项的2倍 list3=[2*x for x in list if x%2==0] print(list3)#[4, 8] list_a=[' ...
同一个路径下a,b,c三个文件   a.py中定义一个函数   def foo(): print("here in foo") return  b.py中定义一个类     class Person(object): def __init__(self): print("new person ")  c.py中调用他们 import a import b #调用 a.foo() aPerson=b.Person()  或者 from a import foo from ...
最简单的javascript类的实现, 缺点所有属性都是公开的   window.onload = function() { var someone = new Person("someone"); var sb = new Person("sb", 99); someone.setName("wod").setAge(100).showInfo(); // alert(typeof Person);//function // alert(typeof someone);//object }; ...
获取浏览器显示区域的高度 : $(window).height();获取浏览器显示区域的宽度 :$(window).width();获取页面的文档高度 :$(document).height();获取页面的文档宽度 :$(document).width();获取滚动条到顶部的垂直高度 :$(document).scrollTop();获取滚动条到左边的垂直宽度 :$(document).scrollLeft();计算元素位置和偏移量offset方法是一个很有用的方法,它返回包装集中第一个元素的偏移信息。默认情况下是相对body的偏移信息。结果包含 top和left两个属性。
//测试结果用 function assert(aBoolean, msg) { if (aBoolean && msg) document.write(msg + "<br/>"); } /*----------------------------- javascript中this比较搞,this是指函数的调用者 */ //功能很简单,返回this function creep() { return this; } //所有直接定义的函数其实都是window的方法,creep( ...
<!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=gbk" /> <title>file</title> <script src="../js/jQuery1.10.2.js"></script> <script src="../js/file.js"></scr ...
<div> <img src=""> </div>   div { margin: 0px; padding: 0px; border: 1px solid red; width: 555px; height: 320px; text-align: center; /*水平居中*/ line-height: 320px; /*垂直居中,等于height,但它只是让图片的下边垂直居中*/ } img { vertical-align: middle; /*图片的中心垂直居中*/ ...
Global site tag (gtag.js) - Google Analytics