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

pythonÄ£¿éѧϰ smtplib Óʼþ·¢ËÍ

ÔÚ»ùÓÚ»¥ÁªÍøµÄÓ¦ÓÃÖУ¬³ÌÐò¾­³£ÐèÒª×Ô¶¯µØ·¢Ë͵ç×ÓÓʼþ¡£È磺һ¸öÍøÕ¾µÄ×¢²áϵͳ»áÔÚÓû§×¢²áʱ·¢ËÍÒ»·âÓʼþÀ´È·ÈÏ×¢²á£»µ±Óû§Íü¼ÇµÇ½ÃÜÂëµÄʱºò£¬Í¨¹ýÓʼþÀ´È¡»ØÃÜÂë¡£smtplibÄ£¿éÊÇpythonÖÐsmtp(¼òµ¥Óʼþ´«ÊäЭÒé)µÄ¿Í»§¶ËʵÏÖ¡£ÎÒÃÇ¿ÉÒÔʹÓÃsmtplibÄ£¿é£¬ÇáËɵķ¢Ë͵ç×ÓÓʼþ¡£ÏÂÃæµÄÀý×ÓÓÃÁ˲»µ½Ê®ÐдúÂëÀ´·¢Ë͵ç×ÓÓʼþ£º
#coding=gbk  
 
import smtplib   
 
smtp = smtplib.SMTP()   
smtp.connect("smtp.yeah.net", "25")   
smtp.login('Óû§Ãû', 'ÃÜÂë')   
smtp.sendmail('from@yeah.net', 'to@21cn.com', 'from: from@yeah.net\r\nTo: to@21cn.com\r\nSubject: this is a email from python demo\r\n\r\nJust for test~_~')   
smtp.quit() 
#coding=gbk
import smtplib
smtp = smtplib.SMTP()
smtp.connect("smtp.yeah.net", "25")
smtp.login('Óû§Ãû', 'ÃÜÂë')
smtp.sendmail('from@yeah.net', 'to@21cn.com', 'from: from@yeah.net\r\nTo: to@21cn.com\r\nSubject: this is a email from python demo\r\n\r\nJust for test~_~')
smtp.quit()
¡¡¡¡Õâ¸öÀý×Ó¹»¼òµ¥°É^_^£¡ÏÂÃæÏêϸ½éÉÜstmplibÄ£¿éÖеÄÀàºÍ·½·¨¡£
smtplib.SMTP([host[, port[, local_hostname[, timeout]]]])
¡¡¡¡SMTPÀ๹Ô캯Êý£¬±íʾÓëSMTP·þÎñÆ÷Ö®¼äµÄÁ¬½Ó£¬Í¨¹ýÕâ¸öÁ¬½ÓÎÒÃÇ¿ÉÒÔÏòsmtp·þÎñÆ÷·¢ËÍÖ¸ÁִÐÐÏà¹Ø²Ù×÷£¨È磺µÇ½¡¢·¢ËÍÓʼþ£©¡£¸ÃÀàÌṩÁËÐí¶à·½·¨£¬½«ÔÚÏÂÃæ½éÉÜ¡£ËüµÄËùÓвÎÊý¶¼ÊÇ¿ÉÑ¡µÄ£¬ÆäÖÐhost²ÎÊý±íʾsmtp·þÎñÆ÷Ö÷»úÃû£¬ÉÏÃæÀý×ÓÖеÄsmtpÖ÷»úΪ"smtp.yeah.net"£»port±íʾsmtp·þÎñµÄ¶Ë¿Ú£¬Ä¬ÈÏÊÇ25£»Èç¹ûÔÚ´´½¨SMTP¶ÔÏóµÄʱºòÌṩÁËÕâÁ½¸ö²ÎÊý£¬ÔÚ³õʼ»¯µÄʱºò»á×Ô¶¯µ÷ÓÃconnect·½·¨È¥Á¬½Ó·þÎñÆ÷¡£
¡¡¡¡smtplibÄ£¿é»¹ÌṩÁËSMTP_SSLÀàºÍLMTPÀ࣬¶ÔËüÃǵIJÙ×÷ÓëSMTP»ù±¾Ò»Ö¡£
¡¡¡¡smtplib.SMTPÌṩµÄ·½·¨£º
SMTP.set_debuglevel(level)
¡¡¡¡ÉèÖÃÊÇ·ñΪµ÷ÊÔģʽ¡£Ä¬ÈÏΪFalse£¬¼´·Çµ÷ÊÔģʽ£¬±íʾ²»Êä³öÈκε÷ÊÔÐÅÏ¢¡£
SMTP.connect([host[, port]])
¡¡¡¡Á¬½Óµ½Ö¸¶¨µÄsmtp·þÎñÆ÷¡£²ÎÊý·Ö±ð±íʾsmptÖ÷»úºÍ¶Ë¿Ú¡£×¢Òâ: Ò²¿ÉÒÔÔÚhost²ÎÊýÖÐÖ¸¶¨¶Ë¿ÚºÅ£¨È磺smpt.yeah.net:25£©£¬ÕâÑù¾Íû±ØÒª¸ø³öport²ÎÊý¡£
SMTP.docmd(cmd[, argstring])
¡¡¡¡Ïòsmtp·þÎñÆ÷·¢ËÍÖ¸Áî¡£¿ÉÑ¡²ÎÊýargstring±íʾָÁîµÄ²ÎÊý


Ïà¹ØÎĵµ£º

python±Ê¼Ç——¹îÒìBUG£¿

×î½üÓÖÖØÐÂ×°ÉÏÁËwindows 7¸Ð¾õ»¹ÊÇÄÇÑù£¬Ö÷ÒªÊÇÏëÓÃM8SDKдЩ³ÌÐò¡£Ò²ÏëÔÚwindowsÉÏÍæÍ棬һֱ¶¼¾õµÃÓÃCдһЩ³£ÓõĶ«¶«ºÜ¸´ÔÓ£¬Ö»ÓнèÖúÓÚ½âÊÍÐÔÓïÑÔÁË£¬ÔÚpython, ruby¼äÑ¡Ôñ£¬×îÖÕÓÃPython¡£
pythonµÄÓï·¨·Ç³£¼òµ¥£¬¶ÔÓÚÒ»¸öѧ¹ý±à³ÌµÄÈË¿ÉÄÜÒ»ÉÏÎç¾Í²î²»¶àÁË£¬²»¹ýpythonµÄÇ¿´óÖ®´¦ÔÚÓÚËüÓÐN¶àµÄ¿â¿ÉÒÔ·½±ãÎÒÃÇ´¦ÀíÎ ......

python ÃüÁîÐвÎÊý


±¾Æª½«½éÉÜpythonÖÐsys, getoptÄ£¿é´¦ÀíÃüÁîÐвÎÊý
Èç¹ûÏë¶Ôpython½Å±¾´«²ÎÊý£¬pythonÖжÔÓ¦µÄargc, argv(cÓïÑÔµÄÃüÁîÐвÎÊý)ÊÇʲôÄØ£¿
ÐèҪģ¿é£ºsys
²ÎÊý¸öÊý£ºlen(sys.argv)
½Å±¾Ãû£º    sys.argv[0]
²ÎÊý1£º     sys.argv[1]
²ÎÊý2£º     sys.argv[2]
test.py
1
import ......

PythonÖ®HTMLParser

"""A parser for HTML and XHTML."""
# This file is based on sgmllib.py, but the API is slightly different.
# XXX There should be a way to distinguish between PCDATA (parsed
# character data -- the normal case), RCDATA (replaceable character
# data -- only char and entity references and end tags a ......

PythonÎļþ²Ù×÷ ´ò¿ª,¶ÁÈ¡,¹Ø±Õ

http://blog.alexa-pro.cn/?p=197
1.´ò¿ªÎļþ´úÂëÈçÏ£º
>>> f = open(”d:test.txt”, “w”)
˵Ã÷£ºµÚÒ»¸ö²ÎÊýÊÇÎļþÃû³Æ£¬°üÀ¨Â·¾¶£»µÚ¶þ¸ö²ÎÊýÊÇ´ò¿ªµÄģʽmode’r'£ºÖ»¶Á£¨È±Ê¡¡£Èç¹ûÎļþ²»´æÔÚ£¬ÔòÅ׳ö´íÎ󣩒w'£ºÖ»Ð´£¨Èç¹ûÎļþ ²»´æÔÚ£¬Ôò×Ô¶¯´´½¨Îļþ£©’a'£º¸½¼ ......

¶ÔPython½ø³Ì½øÐÐÈ«½âÎö

ÏÂÃæ¶ÔPython½ø³Ì½øÐÐÉîÈë¶ø×ÐϸµÄѧϰ£¬Ê×ÏÈÏÈÈôó¼ÒÁ˽âÏÂʲôÊÇPython½ø³Ì£¬ÒÔ¼°ÔÚ¶ÔPython½ø³Ì½øÐд¦ÀíʱעÒâµÄÏà¹ØÎÊÌ⣬½ÓÏÂÀ´£¬¾ÍÓÉÎÒ¸ø´ó¼Ò½øÐнéÉÜѧϰ£¬½ö¹©´ó¼Òѧϰ¡£
²»¹ý£¬ËäÈ»½ø³Ì¿ÉÔÚµ¥¶ÀµÄÄÚ´æ¿Õ¼äÖÐÖ´ÐУ¬µ«³ý·ÇÕâЩPython½ø³ÌÔÚµ¥¶ÀµÄ´¦ÀíÆ÷ÉÏÖ´ÐУ¬·ñÔò£¬Êµ¼Ê²¢²»ÊǓͬʱ”ÔËÐеġ£ÊÇÓɲÙ×÷ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ