PythonÄ£¿éѧϰ
¡¡¡¡ÓÐʱºò£¬Òª°ÑÄÚ´æÖеÄÒ»¸ö¶ÔÏó³Ö¾Ã»¯±£´æµ½´ÅÅÌÉÏ£¬»òÕßÐòÁл¯³É¶þ½øÖÆÁ÷ͨ¹ýÍøÂç·¢Ë͵½Ô¶³ÌÖ÷»úÉÏ¡£PythonÖÐÓкܶàÄ£¿éÌṩÁËÐòÁл¯Óë·´ÐòÁл¯µÄ¹¦ÄÜ£¬È磺marshal, pickle, cPickleµÈµÈ¡£½ñÌì¾Í½²½²marshalÄ£¿é¡£
¡¡¡¡×¢Ò⣺
marshal²¢²»ÊÇÒ»¸öͨÓõÄÄ£¿é£¬ÔÚijЩʱºòËüÊÇÒ»¸ö²»±»ÍƼöʹÓõÄÄ£¿é£¬ÒòΪʹÓÃmarshalÐòÁл¯µÄ¶þ½øÖÆÊý¾Ý¸ñʽ»¹Ã»ÓÐÎĵµ»¯£¬ÔÚ²»Í¬°æ±¾µÄPythonÖУ¬marshalµÄʵÏÖ¿ÉÄܲ»Ò»Ñù¡£Ò²¾ÍÊÇ˵£¬ÓÃpython2.5ÐòÁÐΪһ¸ö¶ÔÏó£¬ÓÃpython2.6µÄ³ÌÐò·´ÐòÁл¯ËùµÃµ½µÄ¶ÔÏ󣬿ÉÄÜÓëÔÀ´µÄ¶ÔÏóÊDz»Ò»ÑùµÄ¡£µ«Õâ¸öÄ£¿é´æÔÚµÄÒâÒ壬ÕýÈçPythonÊÖ²áÖÐËù˵£ºThe marshal
module exists mainly to support reading and writing the “pseudo-compiled” code for Python modules of .pyc
files.
ÏÂÃæÊÇmarshalÄ£¿éÖж¨ÒåµÄһЩÓëÐòÁл¯/·´ÐòÁл¯Óйصĺ¯Êý£º
marshal.dump(value, file[, version])
¡¡¡¡½«ÖµÐ´Èëµ½Ò»¸ö´ò¿ªµÄÊä³öÁ÷Àï¡£²ÎÊývalue±íʾ´ýÐòÁл¯µÄÖµ¡£file±íʾ´ò¿ªµÄÊä³öÁ÷¡£Èç:ÒÔ”wb”ģʽ´ò¿ªµÄÎļþ£¬sys.stdout»òÕßos.popen¡£¶ÔÓÚһЩ²»Ö§³ÖÐòÁÐÀàµÄÀàÐÍ£¬dump·½·¨½«Å׳öValueErrorÒì³£¡£ÒªÌرð˵Ã÷һϣ¬²¢²»ÊÇËùÓÐÀàÐ͵ĶÔÏ󶼿ÉÒÔʹÓÃmarshalÄ£¿éÀ´ÐòÁл¯/·´ÐòÁл¯µÄ¡£ÔÚpython2.6ÖУ¬Ö§³ÖµÄÀàÐͰüÀ¨£ºNone
, integers, long integers, floating point numbers, strings, Unicode objects, tuple, list, set, dict, ºÍ code objects¡£¶ÔÓÚtuple, list, set, dictµÈ¼¯ºÏ¶ÔÏ󣬯äÖеÄÔªËØ±ØÐëÒ²ÊÇÉÏÊöÀàÐÍÖ®Ò»¡£
marshal.load(file)
¡¡¡¡Ö´ÐÐÓëmarshal.dumpÏà·´µÄ²Ù×÷£¬½«¶þ½øÖÆÊý¾Ý·´ÐòÁÐΪPython¶ÔÏó¡£ÏÂÃæÊÇÒ»¸öÀý×Ó£¬ÑÝʾÕâÁ½¸ö·½·¨µÄʹÓãº
1
#
coding=gbk
2
3
import
marshal
,
sys
,
os
4
5
lst
=
[
1
,
(
2
,
"
string
"
)
,
{
"
key
"
:
"
Value
"
}
]
6
7
#
ÐòÁл¯µ½ÎļþÖÐ
8
fle
=
open
(
os
.
path
.
join
(
os
.
getcwd
(
)
,
'
fle
.
txt
'
)
,
'
wb
'
)
9
marshal
.
dump
(
lst
,
fle
)
10
fle
.
close
(
)
11
&nbs
Ïà¹ØÎĵµ£º
from: http://www.chinesepython.org/pythonfoundry/tut2.3/tmp/multiple.html
9.5.1 ¶à¼Ì³Ð Multiple Inheritance
Python supports a limited form of multiple inheritance as well. A class definition with multiple base classes looks as follows:
PythonͬÑùÓÐÏÞµÄÖ§³Ö¶à¼Ì³ÐÐÎʽ¡£¶à¼Ì³ÐµÄÀඨÒåÐÎÈçÏÂÀ ......
import time,thread
def test(a,b):
for i in range(a,b):
time.sleep(1)
print i
def start():
thread.start_new_thread(test,(1,1001))
thread.start_new_thread(test,(1000,2001))
if __name__=='__main__':
start()
......
E-mailÖ÷ÒªÓÉÓʼþÍ·ºÍÓʼþÌåÁ½²¿·Ö×é³É¡£
ÓʼþÍ·ÖеÄÄÚÈݺÍÎÒÃǼÄÐÅʱдÔÚÐÅ·âÉϵÄÄÚÈÝ´óͬСÒ⣬µ±È»ÕâÀïÒ²°üº¬Á˺ܶà·¹ýµÄ“Óʾ֔µÄÐÅÏ¢ÁË¡£
ÓʼþÌåÖеÄÄÚÈݾÍÊÇÎÒÃÇдµÄÐÅ»òÕß°ü¹ü¡£
python×ÔÉí°üº¬ÁËemailÄ£¿é´¦Àí¿ÉÒÔ¿ìËٵĴ¦ÀíE-mailÖеÄÐÅÏ¢
import email
#´ò¿ªÒ»¸öÎļþ
fp = open('email.eml', ' ......
´úÂëºÜ¼òµ¥£¬²»µ½5kÐС£µ«ÊÇ˼·ͦºÃµÄ£¬¸Ä³Énon-blockingÁËÖ®ºóЧÂʾÍÊÇÄÜÌá¸ß²»ÉÙ£¬ÌرðÊÇ¿¼Âǵ½ÏÖ´úµÄweb app¶¼ÐèÒªºÍÆäËûµÄ
HTTP·þÎñÆ÷ͨÐÅ£¬blockingµÄ´ú¼ÛÌ«´óÁË¡£ Tornado is an open source version of the scalable, non-blocking web server and tools that power FriendFeed. The FriendFeed application ......