`
pypy
  • 浏览: 90704 次
  • 性别: Icon_minigender_1
  • 来自: 南京
社区版块
存档分类
最新评论
文章列表
[root@CT53-64-BASE tools]# python Python 2.4.3 (#1, Sep 3 2009, 15:37:37) [GCC 4.1.2 20080704 (Red Hat 4.1.2-46)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import socket >>> s = socket.socket(so ...
jsonkey@ubuntu:~/health$ python Python 2.5.2 (r252:60911, Jul 31 2008, 17:31:22) [GCC 4.2.3 (Ubuntu 4.2.3-2ubuntu7)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import time >>> import datetime & ...
>>> bin = lambda n : (n > 0) and (bin(n/2) + str(n%2)) or '' >>> bin(1) '1' >>> bin(20) '10100' >>>
在linux上工作大家都会用到df命令 [tommy@tommy-1 ~]$ df -h Filesystem Size Used Avail Use% Mounted on /dev/sda5 4.8G 389M 4.2G 9% / /dev/sda7 271G 3.5G 254G 2% /home /dev/sda3 4.8G 1.1G 3.5G 24% /usr /dev/sda2 4.8G 199M 4.3G 5% /var ...
定时获得服务器上内存的使用率 linux的内存使用跟win是不一样的,以下linux命令获得内存使用率是,linux os 预先分配的,实际上可能还没有使用这么多内存,可以使用 $free -m total used free shared buffers cached Mem: 1942 1671 271 0 404 731 -/+ buffers/cache: 535 1406 Swap: ...
最近一个应用特别的吃cpu,又是和已有的应用复用机器,故所以对机器的cpu监控显的重要起来 当cpu高到某一限度,及时报警 def _read_cpu_usage(self): """Read the current system cpu usage from /proc/stat.""" try: fd = open("/proc/stat", 'r') lines = fd.readlines() ...
1. 使用 mplayer分析多媒体文件信息 mplayer -identify -frames 5 -endpos 0 -vo null  YOU-FILE MPlayer SVN-r29319-4.3.2 (C) 2000-2009 MPlayer Team Playing onepiece.mp4. libavformat file format detected. ID_AUDIO_ID=0 [lavf] Audio stream found, -aid 0 ID_VIDEO_ID=1 [lavf] Video stream found, -vid 1 VIDEO:  [avc1] ...
目前开源的转码工具主要有 mplayer & ffmpeg 本篇介绍搭建转码环境(linux平台环境) 1. mplayer http://www.mplayerhq.hu/design7/dload.html configure ./configure --enable-runtime-cpudetection --enable-libavutil_a --enable-libavcodec_a --enable-libavformat_a --enable-libpostproc_a --enable-libswscale_a --prefix=/usr --extr ...
python的异常处理机制设计的比较传统,在日常的开发中,基本满足我的需要 下面就python的异常,几点小小的讨论 1. try...except tommy@lab3:~$ python Python 2.5.2 (r252:60911, Jan 4 2009, 17:40:26) [GCC 4.3.2] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> 1/0 ...
python对数据库的操作大多是基于 MySQLdb 模块 http://mysql-python.sourceforge.net/ 但是,一般情况下大家都很少直接去调用 MySQLdb 去操作数据库 大多会借助 adodb http://phplens.com/lens/adodb/adodb-py-docs.htm 小用了一下 adodb发现,还是比较强大的,(简单,直观) import adodb; conn = adodb.NewADOConnection('mysql') conn.Connect('server','user','pwd','db') curso ...
经常会用到python去调用外部 工具或者命令去干活 有的时候子进程并不按预期退出 比如,子进程由于某种原因挂在那里, 这时候也许,我们有这样一种需求:需要父进程对子进程有监控动作,即,超过一定的时间,就不再等待子进程自己退出,而是去kill子进程,回收资源 以下会列出几张实现方法 1.os.system http://docs.python.org/library/os.html Python 2.5.2 (r252:60911, Jan 4 2009, 17:40:26) [GCC 4.3.2] on linux2 Type "help", &quo ...
当前流行的视频网站,关于视频的在线拖动观看技术的小试, 1.flv文件   flv视频文件,想大家都比较清楚,只要从关键帧的位置切开,并加上"FLV\x1\x1\0\0\0\x9\0\0\0\x9"公共头标志信息,后对任何支持flv视频文件dencoder的播放 ...
最近碰到python向mysql插入中文乱码的问题 SQL_H_UPDATE_DELTA_ITEM = “INSERT INTO delta_item SET hostname=’%(_hostname)s’, itemID=%(_itemID)s, title=%(_title)s, copyright=%(_copyright)s WHERE itemID = %(_itemID)s” # 这里的title,copyright都是中文 # 用python的adodb直接插入,是插入不了的,提示是adodb无法解析SQL语句中的字符串 # 后来从网上查了相关的资料,还是不行,用了utf8 # ...
最近在做一个性能测试,主要是http协议的, 开始想到用C的线程,在后来的试验中发现,C开发多线程还是比较麻烦的, 后来,想到了python,因为是http下载,curl的libcurl def run(self): real_uri=self.get_real_url() if not real_uri: return False try: try: curl = pycurl.Curl() curl.setopt(py ...
lighttpd 中的mod_secure_download.c模块中的防盗链技术大家已经很清楚了,但是这个模块要求会改写一些url的地址,形如: The generated URL has to have the format: <uri-prefix>/<token>/<timestamp-in-hex>/<rel-path> which looks like "yourserver.com/bf32df9cdb54894b22e09d0ed87326fc/435cc8cc/secure.tar.gz" < ...
Global site tag (gtag.js) - Google Analytics