PythonÈëÃŵÄ36¸öÀý×Ó Ö® 18
Àý1£º
# _018
# This is a module (if write Chinese in a module, there will be a error)
def func1():
print 'This is function 1.'
def func2():
print 'This is function 2.'
def func3():
print 'This is function 3.'
# 019
# ʹÓÓimport”Óï¾äµ÷ÓÃÄ£¿é£º
import _018_Module
_018_Module.func1()
_018_Module.func2()
_018_Module.func3()
output£º
This is function 1.
This is function 2.
This is function 3.
Àý2£º
# _018
# This is a module (if write Chinese in a module, there will be a error)
def func1():
print 'This is function 1.'
def func2():
print 'This is function 2.'
def func3():
print 'This is function 3.'
# 020
# ʹÓÓfrom ... import ...”Óï¾äµ÷ÓÃÄ£¿é
from _018_Module import func2
import _018_Module
_018_Module.func1()
func2()
_018_Module.func3()
output£º
This is function 1.
This is function 2.
This is function 3.
Àý3£º
# _018
# This is a module (if write Chinese in a module, there will be a error)
def func1():
print 'This is function 1.'
def func2():
print 'This is function 2.'
def func3():
print 'This is function 3.'
# 021
# ʹÓÓfrom ... import *”Óï¾äµ÷ÓÃÄ£¿é
from _018_Module import *
func1()
func2()
func3()
output£º
This is function 1.
This is function 2.
This is function 3.
Ïà¹ØÎĵµ£º
from: http://www.cnblogs.com/dahuzizyd/archive/2005/03/01/111006.html
pythonÖ§³ÖÃæÏò¶ÔÏóµÄ±à³Ì·ç¸ñ£¬ÕâÀïÖ÷Ҫ˵˵pythonÖеĶà¼Ì³Ð£º
ÏÂÃæµÄ´úÂëʹÓÃpython2.4£¬°²×°ºóʹÓÃidleµÄIDE¿ª·¢»·¾³£¨ËµÊÇIDE £¬±ÈÆðdelphi,VS.netµÈ¼òµ¥µÃÌ«¶àÁË)
´ÓFile-New²Ëµ¥½¨Á¢Ò»¸ö.pyÎļþ£¬Ð´ÏÂÃæµÄ´úÂ룺
class SuperCl ......
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ͬÑùÓÐÏÞµÄÖ§³Ö¶à¼Ì³ÐÐÎʽ¡£¶à¼Ì³ÐµÄÀඨÒåÐÎÈçÏÂÀ ......
¡¡¡¡ÉÏ´Îѧϰ¹ýmarshalÄ£¿éÓÃÓÚÐòÁл¯ºÍ·´ÐòÁл¯£¬µ«marshalµÄ¹¦ÄܱȽϱ¡Èõ£¬Ö»Ö§³Ö²¿·ÖÄÚÖÃÊý¾ÝÀàÐ͵ÄÐòÁл¯/·´ÐòÁл¯£¬¶ÔÓÚÓû§×Ô¶¨ÒåµÄÀàÐ;ÍÎÞÄÜΪÁ¦£¬Í¬Ê±marshal²»Ö§³Ö×ÔÒýÓÃ(µÝ¹éÒýÓÃ)µÄ¶ÔÏóµÄÐòÁл¯¡£ËùÒÔÖ±½ÓʹÓÃmarshalÀ´ÐòÁл¯/·´ÐòÁл¯¿ÉÄܲ»ÊǺܷ½±ã¡£»¹ºÃ£¬python±ê×¼¿âÌṩÁ˹¦Äܸü¼ÓÇ¿´óÇÒ¸ü¼Ó°²È«µÄpickle ......
1. Basic
²Î¿¼¡¶PythonÕýÔò±í´ïʽ²Ù×÷Ö¸ÄÏ¡·
Ä£¿ére£¬perl·ç¸ñµÄÕýÔò±í´ïʽ
regex²¢²»Äܽâ¾öËùÓеÄÎÊÌ⣬ÓÐʱºò»¹ÊÇÐèÒª´úÂë
regex»ùÓÚÈ·¶¨ÐԺͷÇÈ·¶¨ÐÔÓÐÏÞ×Ô¶¯»ú
2. ×Ö·ûÆ¥Åä(ÑÐò½¥½ø)
Ôª×Ö·û
. ^ $ * + ? { [ ] \ | ( )
1) "[" ºÍ "]"³£ÓÃÀ´Ö¸¶¨Ò»¸ö×Ö·ûÀà±ð£¬Ëùν×Ö·ûÀà±ð¾ÍÊÇÄãÏëÆ¥ÅäµÄÒ»¸ö×Ö·û¼¯¡£Èç[ ......
Python´úÂëÓÅ»¯--ÉÙ´ò×ÖС¼¼ÇÉ
˵Ã÷£ºÔö¼Ó´úÂëµÄÃèÊöÁ¦£¬¿ÉÒԳɱ¶¼õÉÙÄãµÄLOC£¬×öµ½¼òµ¥£¬²¢ÇÒÕæÇÐÓÐÁ¦
¹Ûµã£ºÉÙ´ò×Ö£½¶à˼¿¼£«ÉÙ³ö´í£¬10´úÂëÐбÈ50ÐиüÄÜÈÃÈËÃ÷°×£¬ÒÔϼ¼ÇÉÓÐÖúÓÚÌá¸ß5±¶¹¤×÷ЧÂÊ
1. ½»»»±äÁ¿ÖµÊ±±ÜÃâʹÓÃÁÙʱ±äÁ¿£º(cookbook1.1)
ÀÏ´úÂ룺ÎÒÃǾ³£ºÜÊìÁ·ÓÚÏÂÃæµÄ´úÂë
temp = x
x = y
y = ......