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

ÎÊÌâÃèÊö
ÔÚC++ºÍPython»ìºÏ±à³ÌÖУ¬ÔÚÈí¼þ·¢²¼µÄʱºòÐèÒª½«pythonµÄ½âÊÍÆ÷´ò°üµ½°²×°³ÌÐòÖУ¬ÎªÁËÌá¸ßÓû§ÌåÑ飬ÎÒÃÇÐèÒªÈÃÓû§¸Ð¾õ²»µ½pythonµÄ°²×°£¬Èç¹ûÓû§ÒѾ­°²×°ÓÐpythonµÄ»·¾³£¬ÎÒÃÇÒ²Òª±£Ö¤²»Ó°ÏìÏÖÓеÄϵͳ¡£
½â¾ö·½°¸
ÔÚPython2.5ÒÔºó£¬pythonÖ§³Ö´ÓzipÎļþÖжÁÈ¡python½Å±¾Îļþ£¬Ö§³Ö¶ÁÈ¡py£¬pyc£¬pyo£¬²»Ö ......

³õʼ»¯º¯ÊýÖеÄÐ麯Êýµ÷Ó㨠C++ vs python £©

´úÂë+½á¹û£¬²»×ö½âÊÍ
µ±È»£¬¶ÔÓÚpythonûÓÐvirtual functionһ˵£¬¹À¼Æµ±×÷¶Ô±ÈÒ»¸öÀý×Ó¿´¿´°É¡£
#include <iostream>
using namespace std;
class base
{
public:
virtual void foo() { cout << "base" << endl; }
base() { foo() ;}
};
class derive: public base
{
pub ......

python»æÖÆÂÝÐýÏß

#coding=utf-8
from math import sqrt,cos,sin
import Image, ImageDraw
class SpireShape(object):
    def __init__(self, draw):
        self.draw = draw
        self.line_width = 1
     & ......

PythonͨѶ²¾

ÕâÁ½ÌìÔÚѧϰpythonÓïÑÔ£¬Ò²Ñ§×ÅдÁ˸öͨѶ²¾£¬Á·Ï°ÈëÃÅÏ£¡
¹¦ÄÜ°üÀ¨ÒÔÏ£º
1¡¢Ôö¼ÓÒ»Ìõ¼Ç¼
2¡¢É¾³ýÒ»Ìõ¼Ç¼
3¡¢ÐÞ¸ÄÒ»Ìõ¼Ç¼
4¡¢²éѯһÌõ¼Ç¼
5¡¢ÏÔʾÕû¸öͨѶ²¾
6¡¢°ïÖúÌáʾ
7¡¢°æ±¾ÏÔʾ
8¡¢Í˳öµÈ
Ê×ÏȽ¨Á¢Ò»¸öPersonÀ࣬¼´Person.pyÎļþ£¬ÓÃÀ´±£´æÁªÏµÈ˼Ǽ£º
class Person:
def __init__(self, nam ......

pythonÖбàÂëת»»

µ±pythonÖм䴦Àí·ÇASCII±àÂëʱ£¬¾­³£»á³öÏÖÈçÏ´íÎó£º
UnicodeDecodeError: 'ascii' codec can't decode byte 0x?? in position 1: ordinal not in range(128)
0x??Êdz¬³ö128µÄÊý×Ö£¬pythonÔÚĬÈϵÄÇé¿öÏÂÈÏΪÓïÑԵıàÂëÊÇascii±àÂ룬ËùÒÔÎÞ·¨´¦ÀíÆäËû±àÂ룬ÐèÒªÉèÖÃpythonµÄĬÈϱàÂëΪËùÐèÒªµÄ±àÂë¡£
Ò»¸ö½â¾öµÄ·½°¸ÊÇ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ