Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö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¡¢LuaºÍRuby


ÀµÓºÆ(http://blog.csdn.net/lanphaday) Òë
ÒëÕß°´£ºPython¡¢luaºÍrubyÔÚC/C++ÊÇÈÕ½¥Ê½Î¢µÄÇé¿öÏ£¬ÔÚjava/.netµÄΧ¼ßÖÐŬÁ¦¿¹ÕùµÄÈý¸öµ±ºìСÉú¡£ÔÚTom GutschmidtµÄÖø×÷¡¶Game Programmng with Python, Lua and Ruby¡·Ò»ÊéÖУ¬½éÉÜÁËÈýÖÖÓïÑÔÔÚÓÎÏ·ÖеÄÓ¦Óã¬ÆäÖÐÓÈΪÁ˲»ÆðµÄÊÇÔÚÊéÖÐ×îºóÒ»ÕÂÖбȽÏÁËÈýÖֽű¾£¬×÷Õßà ......

PythonÖеÄһЩÒì³£

ÆäʵÒì³£¾ÍÊDz»Õý³££¬¾ÍÊDz»ºÍÎÒÃÇÏëÏóÒ»ÑùÈ¥Ö´ÐС£ËüÊÇÒòΪ³ÌÐò³öÏÖÁË´íÎó¶øÔÚÕý³£¿ØÖÆÁ÷ÒÔÍâ²ÉÈ¡µÄÐÐΪ¡£Python³öÏÖÒì³££¬¾ÍÊÇÒòΪ¼ì²éÁËÒ»¸ö´íÎóʱ£¬Python½âÊÍÆ÷ÎÞ·¨¼ÌÐø¼ÌÐøÖ´ÐÐÏÂÈ¥£¬ÕâʱºòÅ׳öÁËÒì³£¡£ÍùÍùÕâ¸ö´íÎó·ÖΪÓï·¨ÉϺÍÂß¼­ÉÏ(²»Éó¤Ëµ¸ÅÄ-_-! )£¬¿´¿´¼¸¸öÀý×Ó£¬×ܽáһϣº
1¡¢NameError£º³¢ÊÔ·ÃÎÊÒ»¸öÎ ......

PythonÄ£¿éѧϰ urllib


    urllibÄ£¿éÌṩµÄÉϲã½Ó¿Ú£¬Ê¹ÎÒÃÇ¿ÉÒÔÏñ¶ÁÈ¡±¾µØÎļþÒ»Ñù¶ÁÈ¡wwwºÍftpÉϵÄÊý¾Ý¡£Ã¿µ±Ê¹ÓÃÕâ¸öÄ£¿éµÄʱºò£¬ÀÏÊÇ»áÏëÆð¹«Ë¾²úÆ·µÄ¿Í»§¶Ë£¬Í¬ÊÂÓÃC++ÏÂÔØWebÉϵÄͼƬ£¬ÄÇÖÖ“Í´¿à”µÄ±íÇé¡£ÎÒÒÔÇ°·­Òë¹ýlibcurl½Ì³Ì£¬ÕâÊÇÔÚC/C++»·¾³Ï±ȽϷ½±ãʵÓõÄÍøÂç²Ù×÷¿â£¬Ïà±ÈÆðlibcurl£¬PythonµÄurl ......

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ºÅ