07 2017 档案
摘要:1.笛卡尔积在形式上比较容易理解,但作为按钮操作DOM的时候,我的思路大体还可以,有些偏差。看到这种矩行方阵,首先联想到二维数组,事实上这种方法完全可以实现,但是在性能和编码速度上都有弊端。 2.以下是代码
阅读全文
摘要:1.依赖jquery,主要利用二维数组。 2.原生手写。 代码如下: 事实上这个东西还有无限扩展,包括利用vue或react进行dom操作,还有各种接口,商品数量的操作等,时间有限,先这些。
阅读全文
摘要:1.判断是否为二维数组 2.判断某个元素是否在二维数组中(笨方法,效率低,循环嵌套) 3.数组中插入元素的扩展 4.检查DOM元素的自定义属性(我这个依赖jq,可仿制原生)
阅读全文
摘要:今天在某公司面试,做了笔试题,发现并没有理解题目要考什么,总结一下。 1.一个200*200的div在不同分辨率的屏幕上下左右居中,用css实现。 2.写一个左中右布局,占满屏幕,其中左右两块固定宽200,中间自适应宽,要求先加载中间块,写出结构及样式。 3.清除浮动的几种方式: 参考地址:http
阅读全文
摘要:1 服务端 2 #!/usr/bin/python 3 4 from socket import * 5 import sys 6 import os 7 8 class Node(object): 9 def __init__(self,val,next = None): 10 self.val = val 11 ...
阅读全文
摘要:1 在TCP层,有个FLAGS字段,这个字段有以下几个标识:SYN, FIN, ACK, PSH, RST, URG. 2 3 其中,对于我们日常的分析有用的就是前面的五个字段。 4 5 它们的含义是: 6 7 SYN表示建立连接, 8 9 FIN表示关闭连接, 10 11 ACK表示响应, 12 13 PSH表示有 DATA数据传输, 14 15 RST表示连接...
阅读全文
摘要:1 #!/usr/bin/python 2 3 import tornado.httpserver 4 import tornado.ioloop 5 import tornado.options 6 import tornado.web 7 8 from tornado.options import define,options 9 10 define('port',d...
阅读全文
摘要:1 一、连接数据库 2 格式:mysql -h主机地址 -u用户名 -p用户密码 3 1.1.连接到本机上的MYSQL。 4 首先打开DOS窗口,然后进入目录mysql\bin,再键入命令mysql -u root -p,回车后提示你输密码. 5 注意用户名前可以有空格也可以没有空格,但是密码前必须没有空格,否则让你重新输入密码。 6 如果刚安装好MYSQL,超级用户ro...
阅读全文
摘要:1 简单来说,编程中提到的 lambda 表达式,通常是在需要一个函数,但是又不想费神去命名一个函数的场合下使用,也就是指匿名函数。这一用法跟所谓 λ 演算(题目说明里的维基链接)的关系,有点像原子弹和质能方程的关系,差别其实还是挺大的。 2 3 不谈形式化的 λ 演算,只说有实际用途的匿名函数。先举一个普通的 Python 例子:将一个 list 里的每个元素都平方: 4 map( ...
阅读全文
摘要:1 2 1 使用__new__方法 3 Python 4 class Singleton(object): def __new__(cls, *args, **kw): if not hasattr(cls, '_instance'): orig = super(Singleton, cls) cls._instance = orig.__new__(cls, *args, **kw...
阅读全文
摘要:1 %r用rper()方法处理对象 2 3 %s用str()方法处理对象 4 5 有些情况下,两者处理的结果是一样的,比如说处理int型对象。 6 7 例一: 8 9 [python] view plain copy 在CODE上查看代码片派生到我的代码片 10 print "I am %d years old." % 22 11 print "I am %s ye...
阅读全文
摘要:1 项目目录下的urls.py文件默认有admin的url。 2 1.在项目目录下运行manage.py createsuperuser 按提示创建。 3 2. 在app目录下,编辑admin.py 4 # -*- coding: utf-8 -*- 5 from __future__ import unicode_literals 6 7 from django.co...
阅读全文
摘要:1 #coding=utf-8 2 from __future__ import unicode_literals 3 4 from django.shortcuts import render,render_to_response 5 from django.http import HttpRes
阅读全文
摘要:用 __new__函数实现单例模式,主要思想,当创建第二个对象的时候,返回第一个对象
阅读全文
摘要:直接运行代码,浏览器输入 localhost:端口号 即可看到效果。
阅读全文
摘要:简单的Python CGI 在linux平台实现注意:路径是以当前路径为根目录 ,Python文件一般放在/cgi-bin/目录下在linux命令行运行:python -m CGIHTTPServer 8000(端口号默认8000)html文件名设为index.html 测试:本机浏览器 输入 lo
阅读全文
摘要:1 #!/usr/bin/python 2 #coding=utf-8 3 #发送邮件 4 5 import smtplib 6 from smtplib import SMTP as smtp 7 import getpass 8 9 mail_host="smtp.126.com" 10 mail_user="lijunyong3@126.com" 11 mail_p...
阅读全文
摘要:1 #!/user/bin/python 2 #coding=utf-8 3 4 import ftplib 5 import os 6 import socket 7 8 HOST = 'ftp.kernel.org' 9 DIRN = 'pub/linux/kernel' 10 FILE = 'README' 11 12 def main(): 13 try...
阅读全文
摘要:1 #-*- coding: utf-8 -*- 2 #python2.7x 3 4 from pymongo import MongoClient 5 6 def get_db(): 7 #建立连接 8 client = MongoClient("localhost", 27017) 9 #test,还有其他写法 10 db = clien...
阅读全文
摘要:1 2 问题一:以下的代码的输出将是什么? 说出你的答案并解释。 3 class Parent(object): 4 x = 1 5 class Child1(Parent): 6 pass 7 class Child2(Parent): 8 pass 9 print Parent.x, Child1...
阅读全文
摘要:1 #!/usr/bin/python 2 #coding=utf-8 3 #网络爬虫 4 import urllib,re 5 6 def getHtml(url): 7 page=urllib.urlopen(url) #打开一个url 8 html=page.read() #读取全部内容生成一个字符串(对象) 9 return html ...
阅读全文
摘要:1 #!/usr/bin/python 2 #coding=utf-8 3 #server 4 import socket 5 import sys 6 import os 7 8 server_address = './test' 9 10 #首先确保这个文件不能存在,只是用于本地套接字的通信,如果已经存在则不可以了 11 try: 12 os.unlink...
阅读全文
摘要:1 #!/usr/bin/python 2 #coding=utf-8 3 #发送端 4 import sys,struct,socket 5 from time import sleep 6 7 message="hello" 8 message1="nihao" 9 10 multicast_group=('224.3.29.73',10003) 11 multic...
阅读全文
摘要:1 #!/usr/bin/python 2 #coding=utf-8 3 #广播端 4 import sys,socket 5 import time 6 7 s=socket.socket(socket.AF_INET,socket.SOCK_DGRAM) #创建数据报套接字 8 s.setsockopt(socket.SOL_SOCKET,socket.SO_BROAD...
阅读全文
摘要:1 #!usr/bin/python 2 3 from socket import * 4 from select import * 5 from time import ctime 6 s=socket() 7 s.bind(('127.0.0.1',6653)) 8 9 d={s.fileno():s} 10 s.listen(5) 11 12 p=poll() 13...
阅读全文
摘要:1 #实现多任务在同一个线程切换 2 #!/usr/bin/python 3 4 from socket import * 5 from select import * 6 from time import ctime 7 8 sockob=socket(AF_INET,SOCK_STREAM) 9 sockob.bind(("127.0.0.1",7777)) 10 s...
阅读全文
摘要:1 #!/usr/bin/python 2 #coding=utf-8 3 #server 4 from socket import* 5 import sys,os 6 def command(): 7 l=[ "Welcome!\n","command\n", "list\n","upload\n","download\n"] 8 return l 9 d...
阅读全文
摘要:1 #!/usr/bin/python 2 #coding=utf-8 3 #服务器端 4 from socket import * 5 from time import ctime 6 HOST="192.168.1.33" 7 PORT=1235 8 BUFSIZE=1024 9 ADDR=(HOST,PORT) 10 11 sockob=socket(AF_INET...
阅读全文
摘要:1 #!/usr/bin/python 2 #coding=utf-8 3 #服务器端 4 from socket import * 5 from time import ctime 6 7 HOST="192.168.1.33" 8 ADDR=1234 9 t=(HOST,ADDR) 10 11 sockob=socket(AF_INET,SOCK_STREAM) 12 ...
阅读全文
摘要:1 锁 2 Lock() 3 4 Lock(指令锁)是可用的最低级的同步指令。Lock处于锁定状态时,不被特定的线程拥有。Lock包含两种状态——锁定和非锁定,以及两个基本的方法。 5 可以认为Lock有一个锁定池,当线程请求锁定时,将线程至于池中,直到获得锁定后出池。池中的线程处于状态图中的同步阻塞状态。 6 构造方法: 7 Lock() 8 实例方法: 9 acq...
阅读全文
摘要:1 #!/usr/bin/python 2 #coding=utf-8 3 #线程间通信的同步与互斥操作-锁 4 import threading 5 a=b=0 6 lock=threading.Lock() 7 def value(): 8 while 1: 9 lock.acquire() 10 if a!=b: 11 ...
阅读全文
摘要:1 #!/usr/bin/python 2 #coding=utf-8 3 4 import threading,time 5 lock=threading.Condition() 6 product=0 7 class Make(threading.Thread): 8 def __init__(self,lock): 9 self.lock=loc...
阅读全文
摘要:1 #!/usr/bin/python 2 #coding=utf-8 3 #用于线程间通信,通过事件标识控制 4 import threading 5 from time import sleep,ctime 6 7 def A(): 8 print "A is starting" 9 event_is_set=e.wait() 10 print ...
阅读全文
摘要:1 #!/usr/bin/python 2 #coding=utf-8 3 import os,sys,multiprocessing,time 4 try: 5 os.mkfifo('file') 6 except :pass 7 8 9 def read(): 10 try: 11 os.mkfifo('file1') 12 ex...
阅读全文
摘要:1 #!/usr/bin/python 2 #coding=utf-8 3 from time import ctime,sleep 4 import threading 5 6 class Mythead(threading.Thread): 7 def __init__(self,func,args,name=''): 8 super(Mythea...
阅读全文
摘要:1 #!/usr/bin/python 2 import multiprocessing,time 3 4 def A(cond): 5 name=multiprocessing.current_process().name 6 print "starting",name 7 with cond: 8 print "%s is done...
阅读全文
摘要:1 #!/usr/bin/python 2 import threading,time 3 4 def Music(): 5 print "music is playing" 6 time.sleep(3) 7 8 def Movie(): 9 print "Movieis playing" 10 time.sleep(5) 11 12 ...
阅读全文
摘要:1 #!/usr/bin/python 2 from multiprocessing import Process,Lock 3 import time,sys 4 5 def A(lock): 6 with lock: 7 for i in range(10): 8 time.sleep(2) 9 s...
阅读全文
摘要:1 #!/usr/bin/python 2 from multiprocessing import Process,Event 3 import os,time 4 5 def A(e): 6 print "block Process :starting" 7 e.wait() 8 print "event is set >>",e.is_set() ...
阅读全文
摘要:1 #!/usr/bin/python 2 3 from multiprocessing import Process,Queue 4 import time 5 6 l=[] 7 q=Queue() 8 9 def f(name): 10 time.sleep(1) 11 q.put("hello"+str(name)) 12 13 for i in...
阅读全文
摘要:1 #!/usr/bin/python 2 3 import os,time 4 from signal import * 5 6 def get_sig(signum,stack): 7 if signum==SIGINT: 8 print "keep..." 9 elif signum==SIGALRM: 10 prin...
阅读全文
摘要:1 #!/usr/bin/python 2 #coding=utf-8 3 import sys,os 4 from time import sleep 5 6 (r,w)=os.pipe() #创建无名管道,返回两个整数,代表两个管道文件,且代表的功能是(r,w) 7 pid=os.fork() 8 9 if pid<0: 10 print "fail to ...
阅读全文
摘要:1 #!/usr/bin/python 2 #coding=utf-8 3 import multiprocessing 4 5 str= "欢迎来到菜鸟购物系统!" 6 print str.center(80) 7 money=input("请输入您的预算:",) 8 def show(): 9 print '''本商城提供以下商品: 10 ...
阅读全文
摘要:1 #!/usr/bin/python 2 import multiprocessing,time 3 4 class ClockProcess(multiprocessing.Process): 5 def __init__(self,value): 6 super(ClockProcess,self).__init__() 7 sel...
阅读全文
摘要:1 #!/usr/bin/python 2 #coding=utf-8 3 #哈夫曼树创建 4 5 class Node(): 6 def __init__(self,value,left=None,right=None): 7 self.value=value 8 self.left=left 9 self.righ...
阅读全文
摘要:1 #!/usr/bin/python 2 #coding=utf-8 3 class Node(): 4 def __init__(self,value,p=None): 5 self.value=value 6 self.pre=p 7 self.next=p 8 9 class linklist(): 10 ...
阅读全文
摘要:1 #!/usr/bin/python 2 3 class Node(object): 4 def __init__(self,value,next=None): 5 self.value,self.next=value,next 6 7 class Linklist(object): 8 def __init__(self)...
阅读全文
摘要:1 #!/usr/bin/python 2 3 class TreeNode(object): 4 def __init__(self,data = 0,left = None,right = None): 5 self.data = data 6 self.left = left 7 self.right = right...
阅读全文
摘要:1 #!/usr/bin/python 2 #排序方法 3 #冒泡排序 4 def buble(l): 5 for i in range(len(l)): 6 for j in range(len(l)-i-1): 7 if l[j]>l[j+1]: 8 l[j+1],l[j]=l[j],l...
阅读全文
摘要:Python核心数据类型 1.数字(包含整形int 和浮点型 float)字符串(string)(#python中没有字符类型)列表(list)字典(dict) 元组(tuple) 集合 (set)文件 2.其他类型:类类型(object) None(Nonetype) 布尔型(boolean) 3.编程单元模块类型:函数(function) 模块(module) 类(class) 数字类...
阅读全文
摘要:一、安装python 2和3 1.www.python.org下载对应安装包 2.解压进入目录。 3.sudo ./configure 环境配置 4.make 5.sudo make install 安装 问题:cd /usr/bin sudo mv python3 python34 sudo ln -s python3 /usr/local/bin/.python35 二、ipy...
阅读全文
摘要:转自 http://www.imkevinyang.com/2009/07/javascript-中的false零值nullundefined和空字符串对象.html
阅读全文
摘要:转载自:http://www.jb51.net/article/34191.htm
阅读全文
摘要:1 2 3 4 5 猜数 6 7 8 9 10 11 12 猜猜看?! 13 14 101 102
阅读全文
摘要:1 2 3 4 5 6 获取地理位置 7 13 14 15 16 17 18 104 105 106
阅读全文
摘要:1 Math.easeout = function (A, B, rate, callback) { 2 if (A == B || typeof A != 'number') { 3 return; 4 } 5 B = B || 0; 6 rat...
阅读全文
摘要:1 //类级别插件开发,主要是在jQuery中定义全局方法: 2 3 //第一种写法 4 jQuery.myFunc = function(str){ 5 alert("直接在jquery中定义方法",str) 6 } 7 //调用方式 $.myFunc("hello!"); 8 9 //第二种写法 10 jQuery.extend({ 11 myFun...
阅读全文
摘要:cookie,阻止IOS底部拖动,截取地址栏参数,检测特殊字符,身份证号,银行卡号,手机号,移动端meta, cookie : 移动端+PC端 用法: 判断是否运行在微信端: 阻止IOS端 底部拖动: 截取地址栏?后的参数对: 检测是否包含特殊字符: 身份证号校验: 手机号模式匹配: 银行卡格式输入
阅读全文
摘要:1 2 3 4 5 拓扑排序 6 7 8 144 145
阅读全文
摘要:1 2 3 4 5 图的实现 6 7 8 111 112
阅读全文
摘要:1 2 3 4 5 二叉查找树计数 6 7 8 195 196
阅读全文
摘要:1 2 3 4 5 图的实现 6 7 8 105 106
阅读全文
摘要:1 2 3 4 5 二叉查找树 6 7 8 179 180
阅读全文
摘要:1 2 3 4 5 集合 6 7 8 115 116
阅读全文
摘要:1 2 3 4 5 开链散列 6 7 8 82 83
阅读全文
摘要:1 2 3 4 5 线性探测法处理碰撞的散列 6 7 8 线性探测法隶属于开放寻址散列。当发生碰撞时,检查散列中的下一个位置是否为空。如果为空就将数据存入该位置,不为空继续查下去。 9 如果数组的大小是待存储数据个数的1.5倍,那么使用开链法,如果是两倍及以上,使用线性探测法。 ...
阅读全文
摘要:1 2 3 4 5 散列 6 7 8 56 57
阅读全文
摘要:1 2 3 4 5 6 7 8 57 58
阅读全文
摘要:1 2 3 4 5 双向链表 6 7 8 87 88
阅读全文
摘要:1 2 3 4 5 循环链表 6 7 8 73 74
阅读全文
摘要:1 2 3 4 5 6 7 8 73 74
阅读全文
摘要:1 2 3 4 5 JavaScript实现队列 6 7 8 60 61
阅读全文
摘要:1 2 3 4 5 6 7 8 9 82 83
阅读全文
摘要:1 2 3 4 5 6 7 8 109 110
阅读全文
摘要:1 2 3 4 5 js数据结构相关 6 7 8 197 198
阅读全文
摘要:1 2 3 4 5 List实现 6 7 8 181 182
阅读全文
摘要:1 2 3 4 5 Title 6 7 8 138 139
阅读全文
摘要:1 2 3 4 5 javascript高级语法22-观察者模式 6 7 8 9 133 134 135 136 137 138 139 ...
阅读全文
摘要:1 2 3 4 5 javascript高级语法21-命令模式 6 7 8 9 10 11 12 13 14 78 216 ...
阅读全文
摘要:1 2 3 javascript高级语法20-责任链模式 4 5 6 172 173
阅读全文
摘要:1 2 3 4 5 javascript高级语法19-代理模式 6 7 8 250 251
阅读全文
摘要:<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>javascript高级语法18-享元模式</title> </head> <body> <script> /*享元模式是一个为了 提高性能(空间复杂度)的设计模式; * 他使用于
阅读全文
摘要:1 2 3 4 5 javascript高级语法17-装饰者模式下 6 7 8 9 10 11 12 89 90
阅读全文
摘要:1 2 3 4 5 javascript 高级语法16-装饰者模式 6 7 8 199 200
阅读全文
摘要:1 2 3 4 5 javascript高级语法14-组合模式实现 6 7 8 180 181
阅读全文
摘要:1 2 3 4 5 javascript高级语法15-适配器模式 6 7 8 102 103
阅读全文
摘要:1 2 3 4 5 Javascript高级语法13-组合模式 6 7 8 114 115
阅读全文
摘要:1 2 3 4 5 javascript高级语法12-门面模式 6 7 8 click 9 139 140
阅读全文
摘要:1 2 3 4 5 Javascript高级语法11-桥梁模式 6 7 8 109 110
阅读全文
摘要:1 2 3 4 5 Javascript高级语法10-工厂模式实例xhr 6 7 8 134 135
阅读全文
摘要:1 2 3 4 5 javascript高级语法9-工厂模式 6 7 8 550 551
阅读全文
摘要:1 2 3 4 5 javascript高级语法8-链式调用 6 7 8 9 109 110
阅读全文
摘要:1 2 3 4 5 javascript高级语法7-单例模式 6 7 8 145 146
阅读全文
摘要:1 2 3 4 5 javascript高级语法6-封装 6 7 8 178 179
阅读全文
摘要:1 2 3 4 5 javascript高级语法5-接口 6 7 8 192 193
阅读全文
摘要:1 2 3 4 5 javascript高级语法4-继承和聚合 6 7 8 121 122
阅读全文
摘要:1 2 3 4 5 js高级语法3-原型模式 6 7 8 96 97
阅读全文
摘要:1 2 3 4 5 javascript高级语法2-高级类 6 7 8 111 112
阅读全文
摘要:1 2 3 4 5 javascript高级语法1-函数 6 7 8 132 133
阅读全文
摘要:依赖文件地址 :https://github.com/chanceLe/ES6-Basic-Syntax/tree/master/js
阅读全文
摘要:依赖文件地址 :https://github.com/chanceLe/ES6-Basic-Syntax/tree/master/js
阅读全文
摘要:依赖文件地址 :https://github.com/chanceLe/ES6-Basic-Syntax/tree/master/js
阅读全文
摘要:依赖文件地址 :https://github.com/chanceLe/ES6-Basic-Syntax/tree/master/js
阅读全文
摘要:依赖文件地址 :https://github.com/chanceLe/ES6-Basic-Syntax/tree/master/js
阅读全文
摘要:依赖文件地址 :https://github.com/chanceLe/ES6-Basic-Syntax/tree/master/js
阅读全文
摘要:依赖文件地址 :https://github.com/chanceLe/ES6-Basic-Syntax/tree/master/js
阅读全文
摘要:依赖文件地址 :https://github.com/chanceLe/ES6-Basic-Syntax/tree/master/js
阅读全文
摘要:依赖文件地址:https://github.com/chanceLe/ES6-Basic-Syntax/tree/master/js
阅读全文
摘要:依赖文件地址:https://github.com/chanceLe/ES6-Basic-Syntax/tree/master/js
阅读全文
摘要:1.介绍 总的来说,ES6是在ES2015的基础上改变了一些书写方式,开放了更多API,这样做的目的最终还是为了贴合实际开发的需要。如果说一门编程语言的诞生是天才的构思和实现,那它的发展无疑就是不断填坑的历史。ES6正是为了填一些坑。 我对ES6语法的学习,主要在浏览器端,参考阮一峰大神的ES6入门
阅读全文