08 2012 档案

摘要:Decorate是装饰的意思。如果你了解Decorator设计模式,那么就很好理解Python的Decorator。http://en.wikipedia.org/wiki/Python_syntax_and_semantics#DecoratorsDecorator是一个可调用的python object。Decorator可以用来修改funciton, method 或者类的定义。一个object被传进decotator,然后decorator修改这个object并且返回这个object,最后,这个返回的object绑定到原来的那个object的名字上。Decorator是一个语法糖(sy 阅读全文
posted @ 2012-08-25 23:45 semiok
摘要:#!/usr/bin/python# spider version 1# goal: pass -u url -d deep -thread numberimport urllibimport argparseimport threadingimport Queueimport bs4import sysimport timeimport re#import this# #-----------------------------------------------# # bs4 test pass# #-----------------------------------------... 阅读全文
posted @ 2012-08-19 10:19 semiok
摘要:command palette(命令面板):调用:ctrl+shift+p或者tool—command palette 可以搜索命令、选项、snippet 和 syntexfiles间的切换:调用:ctrl+p或者goto—goto anything 切换文件用Command+P可以快速跳转到当前项目中的任意文件,可进行关键词匹配。用Command+P后@(或是Command+R)可以快速列出/跳转到某个函数(很爽的是在 markdown 当中是匹配到标题,而且还是带缩进的!)。用Command+P后#可以在当前文件中进行搜索。用Command+P后:(或是Ctrl+G)加上数字可以跳转到相应 阅读全文
posted @ 2012-08-18 02:16 semiok
摘要:常量: 常量名所有字母大写,由下划线连接各个单词,如: WHITE=0XFFFFFF THIS_IS_A_CONSTANT=1变量:1.普通变量:全部小写,由下划线连接各个单词,如:color=WHITEthis_is_a_variable=12.保护成员变量:单下划线作前缀,意思是只有类对象和子类对象自己能访问到这些变量,且不能用'frommoduleimport*'导入,如:_name=name3.私有成员变量:双下划线作前缀,意思是只有类对象自己能访问,连子类对象也不能访问到这个数据,如:__ha=ha4.全局变量:大写字母,单词之间用_分割,对于fromMimport* 阅读全文
posted @ 2012-08-16 15:35 semiok
摘要:# -*- coding: utf-8 -*- import argparse args = "-f hello.txt -n 1 2 3 -x 100 -y b -z a -q hello @args.txt i_am_bar -h".split() # 使用@args.txt要求fromfile_prefix_chars="@" # args.txt文件中应该一行一个参数,想改变行为参考convert_arg_line_to_args() # ArgumentParser参数的简单说明 ## description - 命令行帮助的开始文字,大部分情 阅读全文
posted @ 2012-08-16 01:10 semiok
摘要:【source link:http://www.2cto.com/kf/201203/124801.html】一、 Python 中的线程使用: Python中使用线程有两种方式:函数或者用类来包装线程对象。1、 函数式:调用thread模块中的start_new_thread()函数来产生新线程。如下例: import time import thread def timer(no, interval): cnt = 0 while cnt<10: print 'Thread:(%d) Time:%s\n'%(no, time.ctime(... 阅读全文
posted @ 2012-08-15 22:46 semiok