省朝夕

 

python备注点


1、计算时间差:
import datetime
starttime = datetime.datetime.now()
endtime = datetime.datetime.now()
print (endtime - starttime).seconds
2、执行shell命令:
import subprocess
ret = subprocess.Popen(CMD,shell=True,stdout=subprocess.PIPE,stderr=subprocess.STDOUT)
for line in ret.stdout.readlines():
    print line
3、简单的urllib2使用:
import urllib2
res=urllib2.urlopen(url)
print res.read()

posted on 2013-01-18 12:03 hejianchao 阅读(136) 评论(0)  编辑  收藏 所属分类: python


只有注册用户登录后才能发表评论。


网站导航:
 

导航

统计

留言簿

文章分类

文章档案

搜索

最新评论