python½Å±¾Ä£Äâä¯ÀÀÆ÷
£¨Å¼¶û¿´µ½£¬ÅÂÍüÁË£©
·ÂÓû§´ò¿ªä¯ÀÀÆ÷È»ºóµã»÷µÈÐÐΪȻºó»ñÈ¡½á¹û£¬ÒÔÏÂÊÇÎÒʹÓùýµÄ·½·¨Ö»ÊÇÒÀÀµÓëie²»¹ýfirefoxµÈÓ¦¸ÃÒ²ÓÐÏàÓ¦µÄµ÷Ó÷½·¨£º
˼·¾ÍÊǵ÷ÓÃieµÄcom×é¼þÈ»ºó¾ÍÊǶÔdomµÄ²Ù×÷¸úÓÃjavascript²Ù×÷domÀàËÆ£¬Ê¾·¶´úÂëÈçÏÂ
#ÌìÑĵǽµØÖ·
tianyalogin = "http://www.tianya.cn/"
tianya_user = "xxxxx"
tianya_pw = "xxxxx"
ie = win32com.client.Dispatch("InternetExplorer.Application")
ie.Visible = 0
#¿ªÊ¼µÇ½
ie.Navigate(tianyalogin)
state = ie.ReadyState
print "´ò¿ªµÇÂ½Ò³Ãæ"
while 1:
state = ie.ReadyState
if state ==4:
break
sleep(1)
print "Ò³ÃæÔØÈëÍê±Ï£¬ÊäÈëÓû§ÃûÃÜÂë"
state = None
ie.Document.getElementById("text1").value=tianya_user
ie.Document.getElementById("password1").value=tianya_pw
ie.Document.getElementById("button1").click()
while 1:
state = ie.ReadyState
print state
if state ==4 and str(ie.LocationURL) == "http://
cache.tianya.cn/index.htm":
break
sleep(1)
print "µÇ½³É¹¦"
Ïà¹ØÎĵµ£º
client:
import socket, sys
if __name__ == '__main__':
#´¦Àí²ÎÊý
argv = sys.argv
if (len(argv)!=3) or (len(argv)==2 and argv[1]=='/?'):
print '>>>Useage:', argv[0], '<address> < ......
ÔÚPythonÖÐÓÐÐ©ÌØÊâµÄµØ·½ÊÇ´æÔÚÁ½ÖÖ×Ö·û´®£¬·Ö±ðΪstrºÍunicode×Ö·û´®£¬ËûÃǶ¼¼Ì³Ð×Ôbasestring¡£
È磺s="hello world"£¬sΪstr£»us=u"hello world"£¬usΪunicode¡£
ʹÓÃhelp(str)ºÍhelp(unicode)¿ÉÒԲ鿴¸÷×Ô˵Ã÷£¬ËûÃǶ¼ÓÐdecode¡¢encode·½·¨£¬
decodeÓÃÓÚ½«str×Ö·û´®½âÂëΪunicode×Ö·û´®£¬
encodeÓÃÓÚ½«unicode×Ö·û ......
ÔÚpythonÖУ¬ÈκÎÊý¾ÝÀàÐͶ¼ÊÇ“¶ÔÏ󔣬°üÀ¨pythonÌṩµÄÄÚÖöÔÏó£¬Ò²°üÀ¨Óû§Í¨¹ýpythonÓïÑÔ»òÕßCÀ©Õ¹¿â´´½¨µÄ¶ÔÏó¡£
pythonµÄ¶ÔÏóÊǶ¯Ì¬ÀàÐÍ£¬¶øÇÒÊÇÇ¿ÀàÐÍ£¬ÕâÒâζ×ÅÖ»ÓÐÀàÐÍÆ¥ÅäµÄʱºò²ÅÄܽøÐÐÏàÓ¦µÄ²Ù×÷¡£ÏÖÔÚ£¬ÎÒÃÇÀ´Ñ§Ï°pythonµÄÄÚÖöÔÏó£¬pythonµÄÄ ......
pythonµÄsmtplibÌṩÁËÒ»Öֺܷ½±ãµÄ;¾¶·¢Ë͵ç×ÓÓʼþ¡£Ëü¶ÔsmtpÐÒé½øÐÐÁ˼òµ¥µÄ·â×°¡£
smtpÐÒéµÄ»ù±¾ÃüÁî°üÀ¨£º
HELO Ïò·þÎñÆ÷±êʶÓû§Éí·Ý
MAIL ³õʼ»¯Óʼþ´«Êä mail from:
&nb ......
>>> a = {'1':'2'}
>>> b = {'3':'4'}
>>> a+b
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: unsupported operand type(s) for +: 'dict' and 'dict'
>>> a.update(b)
>>> a
{'1': '2', '3': '4'} ......