![](https://img-blog.csdnimg.cn/20201014180756913.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
python
文章平均质量分 74
qweasdzxcpkh
这个作者很懒,什么都没留下…
展开
-
python多进程
os.fork()方法该方法会衍生出一个子进程,父进程和子进程都会执行接下来的代码,方法返回值根据进程不同,父进程返回>0的一个数值,子进程返回0。想获得操作系统层面上的进程id需要调用os.getpid()创建子进程后,父进程退出后子进程也会被回收,所以父进程一般需要调用os.wait()或os.waitpid()方法等待子进程结束os.wait()等待任意一个子进程结束转载 2017-05-24 18:26:19 · 241 阅读 · 0 评论 -
python变量笔记
Python中,变量不是强制类型,定义变量不需类型声明Python有五个标准的数据类型:Numbers(数字)String(字符串)List(列表)Tuple(元组)Dictionary(字典)数字又分为:int(有符号整型)long(长整型[也可以代表八进制和十六进制]) float(浮点型) complex(复数)字符串是可索引的:print转载 2017-05-13 18:37:45 · 142 阅读 · 0 评论 -
python多线程
模块有两个:threading和threadthread模块实现多线程:a=0def funt(no,b): global a while True: a+=1 print 'thread no %d = %d' %(no,a)def test(): thread.start_new_thre原创 2017-05-25 01:44:27 · 187 阅读 · 0 评论 -
python线程锁
threading模块中有线程锁的功能,避免对公共资源操作导致的不可预计的后果使用方法:lock=threading.RLock 或者 lock=threading.Lock()然后再线程中使用lock.acquire()方法加锁,用lock.release()解锁比如: def run(self): global count whil原创 2017-05-25 01:56:11 · 192 阅读 · 0 评论 -
python模块sys与os还有内置函数
系统相关的信息模块: import syssys.argv 是一个 list,包含所有的命令行参数. sys.stdout sys.stdin sys.stderr 分别表示标准输入输出,错误输出的文件对象. sys.stdin.readline() 从标准输入读一行 sys.stdout.write("a") 屏幕输出a sys.exit(exit_code) 退出程转载 2017-05-18 02:42:11 · 367 阅读 · 0 评论 -
django中的csrf与后台模块处理
在表单中使用post方法提交表单数据,需要使用csrf标签,这是Django提供的防止伪装提交请求的功能。get方法提交数据不用使用csrf用法:模板中: {% csrf_token %} 模块中:def query(request): if request.POST.has_key("productname"):转载 2017-06-05 21:58:20 · 625 阅读 · 0 评论 -
python生成器
defodd(): n=1 whileTrue: yieldn n+=2odd_num =odd()count= 0for oin odd_num: print(o) count+=1关键字:yield有yield的函数会变成生成器,好处是不像列表原创 2017-06-01 19:01:31 · 184 阅读 · 0 评论 -
python正则表达式
模块:reimport re方法主要有:p=re.compile(r"abc") 返回pattern对象p.match("str") 返回str中符合该pattern对象的字符串#p.search("str") 返回str中符合该pattern对象的字符串#p.findall("str") 返回list对象区别:match方法必须要求原创 2017-06-01 18:20:26 · 296 阅读 · 0 评论