Ò׽ؽØÍ¼Èí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

python·¢ÓʼþµÄ´úÂë

# -*- coding: cp936 -*-
from email.MIMEText import MIMEText
from email.MIMEMultipart import MIMEMultipart
import smtplib
 
#´´½¨Ò»¸ö´ø¸½¼þµÄʵÀý
msg = MIMEMultipart()
#¹¹Ô츽¼þ
att = MIMEText(open('e:\\test.txt').read(), 'base64', 'gb2312')
att["Content-Type"] = 'application/octet-stream'
#att["Content-Disposition"] = 'attachment; filename="e:\\test.txt"' ÒÔ¸½¼þÐÎʽ·¢ËÍ
msg.attach(att)
mailto_list=["wsywfw3@163.com"]
#####################
# ÉèÖ÷þÎñÆ÷£¬Óû§Ãû¡¢¿ÚÁîÒÔ¼°ÓÊÏäµÄºó׺
mail_host="smtp.163.com"
mail_user="wsywfw3@163.com"
mail_pass="7451920"
mail_postfix="163.com"
######################
def send_mail(to_list,sub,content):
    '''
    to_list:·¢¸øË­
    sub:Ö÷Ìâ
    content:ÄÚÈÝ
    send_mail("aaa@126.com","sub","content")
    '''
    me=mail_user+"<"+mail_user+"@"+mail_postfix+">"
    msg = MIMEText(content)
    msg = att
    msg['Subject'] = sub
    msg['from'] = me
    msg['To'] = ";".join(to_list)
    try:
        s = smtplib.SMTP()
        s.connect(mail_host)
        s.login(mail_user,mail_pass)
        s.sendmail(me, to_list, msg.as_string())
        s.close()
        return True
    except Exception, e:
        print str(e)
        return False
if __name__ == '__main__':
    if send_mail(mailto_list,"subject","content"):
  


Ïà¹ØÎĵµ£º

UBUNTU10.04°²×°stackless pythonÔËÐиßÐÔÄÜ·þÎñÆ÷

ÒÔÏÂ"#"¿ªÍ·ÊÇUbuntuÖÕ¶ËÃüÁî
1¡£Ê×ÏȰ²×°Ubuntu10.04
²Î¿¼ http://wiki.ubuntu.org.cn/
2¡£ÐÞ¸ÄrootÓû§ÃÜÂë
3¡£Ê¹ÓÃrootµÇ½ϵͳ
 
4¡£UbuntuĬÈÏÒѾ­°²×°python2.6.5
 
5¡£ÏÂÔØstackless
²é¿´ÍøÖ· http://zope.stackless.com/download/sdocument_view
# cd /usr/src
# wget http://www.sta ......

ÓÃpy2exe±àÒëPython³ÌÐò

£¨Ò»£© py2exe¼ò½é
      py2exeÊÇÒ»¸ö½«python½Å±¾×ª»»³ÉwindowsÉϵĿɶÀÁ¢Ö´ÐеĿÉÖ´ÐгÌÐò(*.exe)µÄ¹¤¾ß£¬ÕâÑù£¬Äã¾Í¿ÉÒÔ²»ÓÃ×°python¶øÔÚ
windowsϵͳÉÏÔËÐÐÕâ¸ö¿ÉÖ´ÐгÌÐò¡£
¡¡¡¡
¡¡¡¡py2exeÒѾ­±»ÓÃÓÚ´´½¨
wxPython,Tkinter,Pmw,PyGTK,pygame,win32com
clientºÍserver,ºÍÆäËüµÄ¶ÀÁ¢³ ......

ʹÓÃCÓïÑÔÀ©Õ¹Python(Èý)

ÉÏһƪÖÐÎÒÃÇÒѾ­Á˽âÈçºÎÔÚPython³ÌÐòºÍCÄ£¿éÖ®¼ä½øÐÐÖµµÄÏ໥´«µÝ£¬ÏÖÔÚÎÒÃÇÀ´½øÈëʵ×÷½×¶Î£¬¿´¿´ÈçºÎ½«Ò»¸öCÓïÑÔ¿ª·¢µÄ¿ªÔ´mp3±à½âÂë¿âLAME°üװΪһ¸öPythonÏ¿ÉÒÔʹÓõÄÀ©Õ¹Ä£¿é¡£Ê×ÏÈÈ¥http://lame.sourceforge.net/download.phpÏÂÔØLAMEµÄÔ´´úÂ룬ȻºóÇл»µ½rootÓû§±àÒëÔ´´úÂ룬./configure
make
make instal ......

python joinµÄÓ÷¨

>>> a="abcd"
>>> ",".join(a)
'a,b,c,d'
>>> "|".join(['a','b','c'])
'a|b|c'
>>> ",".join(('a','b','c'))
'a,b,c'
>>> ",".join({'a':1,'b':2,'c':3})
'a,c,b' ......

Python×Ö·û´®²Ù×÷[ת]


Python×Ö·û´®²Ù×÷
pythonÈçºÎÅжÏÒ»¸ö×Ö·û´®Ö»°üº¬Êý×Ö×Ö·û 
python ×Ö·û´®±È½Ï 
ÏÂÃæÁгöÁ˳£ÓõÄpythonʵÏÖµÄ×Ö·û´®²Ù×÷
1.¸´ÖÆ×Ö·û´®
#strcpy(sStr1,sStr2)
sStr1 = 'strcpy'
sStr2 = sStr1
sStr1 = 'strcpy2'
print sStr2
2.Á¬½Ó×Ö·û´®
#strcat(sStr1,sStr2)
sStr1 = 'strcat'
sStr2 = 'appen ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ