摘要:        
#-*-coding:UTF-8-*-#打包python类库#发布第一个python包非常困难#Distutils安装脚本应命名为setup.py#编写安装脚本from distutils.core import setup #每个Distutils安装脚本的第一行,导入setup()...    阅读全文
        
            posted @ 2012-04-01 15:52
jianhong
阅读(181)
评论(0)
推荐(0)
        
        
            
        
        
摘要:        
当面对一串不知道编码信息的字节流的时候,尝试着确定一种编码方式以使我们能够读懂其中的文本内容。类似于破解密码。Firefox包含有一个自动检测字符编码的库,导入到了python2,并且取绰号为chardet模块 chardet运用了一种算法来检测字符的类型import chardetutf8_st...    阅读全文
        
            posted @ 2012-04-01 15:36
jianhong
阅读(205)
评论(0)
推荐(0)
        
        
            
        
        
摘要:        
#-*-coding:UTF-8-*-#HTTP Web服务import urlliba_url='http://www.baidu.com'data=urllib.urlopen(a_url).read(10)print data    阅读全文
        
            posted @ 2012-04-01 15:20
jianhong
阅读(96)
评论(0)
推荐(0)
        
        
            
        
        
摘要:        
#-*-coding:UTF-8-*-#序列化python对象entry=[1,2,3,4,5,6,7,8,9,0]import picklewith open("entry.pickle",'wb') as f: pickle.dump(entry,f) ...    阅读全文
        
            posted @ 2012-04-01 15:06
jianhong
阅读(247)
评论(0)
推荐(0)
        
        
            
        
        
摘要:        
#-*-coding:UTF-8-*-#python xml 文件操作import xml.etree.ElementTree as etree #ElementTree属于python标准库的一部分tree=etree.parse('feed.xml') #parse()函数会立...    阅读全文
        
            posted @ 2012-04-01 13:29
jianhong
阅读(185)
评论(0)
推荐(0)
        
        
            
        
        
摘要:        
#-*-coding:UTF-8-*-#python文件操作#字符对象操作import localeprint locale.getpreferredencoding() #得到系统默认的编码信息with open('C:\Users\Administrator\Desktop\...    阅读全文
        
            posted @ 2012-04-01 13:05
jianhong
阅读(212)
评论(0)
推荐(0)
        
        
            
        
        
摘要:        
python2.6 下载wget http://www.python.org/ftp/python/2.6.7/Python-2.6.7.tgz 解压 tar –zxvf python-2.6.7.tgz cd python-2.6.7 ./configure make make install 替...    阅读全文
        
            posted @ 2012-04-01 10:53
jianhong
阅读(191)
评论(0)
推荐(0)
        
        
            
        
        
摘要:        
现在的软件开发过程中,测试往往关系到一个项目的成败。所以,我们非常有必要学习如何测试自己所编写的代码。那么,python能够在这方面做些什么呢? 首先,我们编写一个自己的类文件。 例1. widget.pyclass Widget: def __init__(self,size=(40,40...    阅读全文
        
            posted @ 2012-04-01 10:39
jianhong
阅读(245)
评论(0)
推荐(0)
        
        
            
        
        
摘要:        
在python中,assert用来实现断言的功能:#-*-coding:UTF-8-*-#python的断言机制assert 1+1==2assert 1+1==3 #assert语句后面跟任何合法的python表达式,如果后面的表达式为True,则assert不做任何事情,如果为f...    阅读全文
        
            posted @ 2012-04-01 09:25
jianhong
阅读(230)
评论(0)
推荐(0)
        
        
            
        
        
摘要:        
很简单,用python的set()内建函数就可以实现:#-*-coding:UTF-8-*-#在序列中寻找不同的元素a_list=[1,1,2,2,3,4,5,6,7]print set(a_list) #set函数将返回一个没有重复项的集合a_string='AABB...    阅读全文
        
            posted @ 2012-04-01 09:14
jianhong
阅读(367)
评论(0)
推荐(0)
        
        
 
                    
                     
                    
                 
                    
                 
         浙公网安备 33010602011771号
浙公网安备 33010602011771号