python exceptions
摘要:1 # encoding: utf-8 2 # module exceptions 3 # from (built-in) by generator 1.100 4 """ 5 Python's standard exception class hierarchy. 6 7 Exceptions found here are defined both in the exceptions module and the 8 built-in namespace. It is recommended that user-defined exceptions 9
阅读全文
posted @
2013-05-30 17:55
呆头龙
阅读(443)
推荐(0)
python 自己实现for循环:
摘要:def for_loop(start,step): step = 10 while 1: yield start start+= step #调用方法如if __name__== '__main__': start = 1 end = 10000 for i in for_loop(start,step): if i >= end: break print i
阅读全文
posted @
2012-12-15 15:59
呆头龙
阅读(276)
推荐(0)
去除(UTF-8)格式文本中的Bom
摘要:def trimFile(name): file = open(name,'rb') content = file.read(3) if content != '\xEF\xBB\xBF': return False content = file.read() file.close() file = open(name,'wb') file.write(content) file.close print 'convert ',name,' finish' return True
阅读全文
posted @
2012-12-12 17:35
呆头龙
阅读(256)
推荐(0)
ffmpeg 视频转换和截图 方法
摘要:来源:http://www.ffmpeg.com.cn/index.php/Ffmpeg%E5%BF%AB%E9%80%9F%E5%91%BD%E4%BB%A4%E4%BD%BF%E7%94%A8Ffmpeg使用语法ffmpeg [[options][`-i' input_file]]... {[options] output_file}...如果没有输入文件,那么视音频捕捉(只在Linux下有效,因为Linux下把音视频设备当作文件句柄来处理)就会起作用。作为通用的规则,选项一般用于下一个特定的文件。如果你给 –b 64选项,改选会设置下一个视频速率。对于原始输入文件,格式选项可能是
阅读全文
posted @
2012-12-01 11:49
呆头龙
阅读(1307)
推荐(0)
Beautiful Soup 使用
摘要:Beautiful Soup 使用参考Beautiful Soup 类图结构(红色部分框内为常用的类):待续...
阅读全文
posted @
2012-09-07 10:53
呆头龙
阅读(248)
推荐(0)
python 的日志logging模块学习
摘要:转自:from:http://blog.csdn.net/yatere/article/details/66554451.简单的将日志打印到屏幕importlogginglogging.debug('This is debug message')logging.info('This is info message')logging.warning('This is warning message')屏幕上打印:WARNING:root:This is warning message默认情况下,logging将日志打印到屏幕,日志级别为WARNIN
阅读全文
posted @
2012-09-05 11:20
呆头龙
阅读(496)
推荐(0)
PyQt入门,一个简单的文本编辑器
摘要:使用QtDesigner创建UI界面如图,给关闭按钮添加关闭操作/form命名为:notepad打开按钮命名为:button_open保存按钮命名为:button_save文件名保存为notepad.ui2.使用pyuic编译ui文件为py文件 : pyuic4 notepad.ui > notepad.py 编译后为打开文件notepad.py,代码为:# -*- coding: utf-8 -*-# Form implementation generated from reading ui file 'C:\Users\Administrator\Desktop\testqt
阅读全文
posted @
2012-08-24 16:26
呆头龙
阅读(3378)
推荐(1)
Python socket编程
摘要:一个简单的python socket编程一、套接字套接字是为特定网络协议(例如TCP/IP,ICMP/IP,UDP/IP等)套件对上的网络应用程序提供者提供当前可移植标准的对象。它们允许程序接受并进行连接,如发送和接受数据。为了建立通信通道,网络通信的每个端点拥有一个套接字对象极为重要。套接字为BSD UNIX系统核心的一部分,而且他们也被许多其他类似UNIX的操作系统包括Linux所采纳。许多非BSDUNIX系统(如ms-dos,windows,os/2,mac os及大部分主机环境)都以库形式提供对套接字的支持。三种最流行的套接字类型是:stream,datagram和raw。stream
阅读全文
posted @
2012-08-08 15:37
呆头龙
阅读(2311)
推荐(0)