易截截图软件、单文件、免安装、纯绿色、仅160KB

python pop3 收邮件

def retrive_emails(pop3_server, user_name, passwd, server_port):
    #POP3
    pop_client = poplib.POP3(pop3_server, port=server_port)
    pop_client.user(user_name)
    pop_client.pass_(passwd)
   
    #print messages num
    num_messages, mbox_size = pop_client.stat()
    print 'there are %s new emails\n' % num_messages
    if num_messages == 0:
        pop_client.quit()
        return
    print('num of messages %s' %str(num_messages))
   
    #mk folder
    folder_name = '%s-%s' %(user_name, pop3_server)
    if not os.path.exists(folder_name):
        os.mkdir(folder_name)
       
    for idx in range(num_messages):         
        one_mail = pop_client.retr(idx+1)
        buf = cStringIO.StringIO()
        for j in one_mail[1]:           
            print >>buf,j 
        buf.seek(0)
       
        #parse mail content
        msg = email.message_from_file(buf)
        for part in msg.walk():
            contenttype = part.get_content_type()
            print('\npart:\n%s\n' % part)
      &


相关文档:

Python常用模块下载链接

Python http://www.python.org/download/ wxPython http://www.wxpython.org/download.php#binaries Vpython http://vpython.org/contents/download_windows.html Matplotlib http://sourceforge.net/projects/matplotlib/files/matplotlib/ PyGlet http://www.pyglet.org/download.html PyGame http://www.pyga ......

python写的将一些类型的文件压缩为7z格式

#将一些类型的文件压缩为7z.py
#for folder all file do 7z
import os
import sys
import distutils.file_util
def ImportOkFile():
    if(os.path.isfile("D:\\Records\\将一些类型的文件压缩为7z_record.txt")==False):
        f=open("D:\\Reco ......

Ruby和Python的语法比较


Ruby和Python的语法比较
 
 
 
其实Ruby和Python非常接近,比大多数别的语言要接近的多,所以喜欢用啥就用啥(大实话,虽然也是废话)。语法上的差别虽然有那么一点,大部分是syntax sugar,我斗胆稍微列几个(python我也忘得差不多了,不对的大家尽管来鞭尸吧),但是主要差异还是设计思想上的:灵活 ......

python 读http小记

conn = httplib.HTTPConnection(EPG_IP + ":" + HTTP_PORT)
url = FAV_URL_PARTH +"userid=" + USER_ID + FAV_DIR_MODIFY
param = '''<ps100request id="Favorite.Category.modify">
<categoryid>'''+categoryid+'''</categoryid>
<categoryname>'''+categoryname+'''</ ......

python的异常Exception


Python 的异常处理机制
Python代码 
 try:    
  raise Exception("a", "b")    
    except Exception,e:    
  print e    
    finally:    
  print "final"    
('a', ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号