天天看点

python 相关

  1. Threading模块

    http://python.jobbole.com/81546/

    Threading.thread(target,name,args,kwargs)

    Threading.Lock.aquire()  Threading.Lock.lock.release() 锁

    Thread.name  Thread.isAlive

       Thread.startup()  

       Thread.join(timeout)  阻塞,直到线程结束或超时

join方法,如果一个线程或者一个函数在执行过程中要调用另外一个线程,并且待到其完成以后才能接着执行,那么在调用这个线程时可以使用被调用线程的join方法。

是主进程挨个调用子线程的join()方法。当四个线程都执行完毕后,主线程才会执行下面的代码

setDaemon()

这个方法基本和join是相反的

只要主线程完成了,不管子线程是否完成,都要和主线程一起退出,

threading.Condition

condition.wait(timeout)   condition.notify()   condition.notifyAll()

threading.Event     threading.Timer

2.Threading函数 调用另一个函数参数(pythings->threading->exercise)

http://www.zhihu.com/question/28127613/answer/39509912

global 变量,self.xxx 变量,callback函数,self._xxx 变量 ...

3. python 调用tcl函数,并引用tcl终端变量

http://liangqiu.blog.51cto.com/4461709/786898

然后是python调用tcl:

#!/usr/bin/python

from Tkinter import Tcl

#建立一个tcl的解释器

tcl = Tcl()

#导入tcl文件

tcl.eval('source helloworld.tcl')

#调用函数,tcl_str为返回值

tcl_str=tcl.eval('Factorial %d' % 10)

print tcl_str

4.OS

os.path.isdir('./file')   os.path.exists('ss.txt') 

os.mkdir('C:\\ x\x ')   os.mkdir('./file')

os.popen('shell command')

os.listdir('//192.168.0.102/SharedDocs')

os.system( 'ipconfig')

5.random

from random import randint

randint(a,b)         random() -> x in the interval [0, 1).

6.python调用py脚本   为xxx,py 中的变量赋值,同时调用xxx的类和函数

 xxx.py      class  cxx()          def __init__(self,arg)   def func()

import xxx          

x = xxx.cxx(arg)

7.排序

l.sorted()

sorted(dict.iteritems(),key=lambda d:d[1],reverse=True)

8.re 正则表达式

 http://www.cnblogs.com/huxi/archive/2010/07/04/1771073.html

9.BeautifulSoup

http://cuiqingcai.com/1319.html

10.requests

s=requests.get(url)    s.text     s.encoding = 'utf-8'

11.xlrd, xlwt, xlutils,  pywin32 to Excel

http://www.2cto.com/kf/201408/322437.html

http://blog.csdn.net/tianzhu123/article/details/7225809

pywin32 to Excel

http://blog.csdn.net/qdx411324962/article/details/44270455

继续阅读