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ͬÑùÓÐÏÞµÄÖ§³Ö¶à¼Ì³ÐÐÎʽ¡£¶à¼Ì³ÐµÄÀඨÒåÐÎÈçÏÂÀ ......
ÔÚÍøÉÏËѲ»µ½¹ØÓÚ Ascii ºÍ bcd»¥Ïàת»¯µÄÎÄÕ£¬ÓÚÊÇ×Ô¼ºÐ´ÁËÒ»¸ö£¬ºÍ´ó¼Ò·ÖÏíÏ¡£
ûÓп¼Âǵ½Ð§ÂÊ£¬Äܹ»ÓÅ»¯µÄµØ·½Íû´ó¼ÒÌá³ö
"""
AscII×Ö·ûת»»ÎªBCD×Ö·û
"""
def asc2bcd(inAsc, pad_L0_R1 = 0):
#È«²¿×ª»»Îª´óд£¬ÎªºóÃæµÄת»»Ìṩ·½±ã
inAsc = inAsc.upper()
&nb ......
´ÓMoteLab·µ»ØµÄ´®¿ÚÊý¾Ý£¬°üº¬messages.pickleÎļþÕâÊÇMoteLabϵͳÖд®¿ÚÊÕ¼¯Êý¾ÝµÄ×ܺͣ¬µ«ÊÇÕâЩÊý¾ÝÐèÒª½âÎöºó²ÅÄܽøÐзÖÎö¡£ÏÂÃæµÄ´úÂë¾ÍÊÇÔÚpython»·¾³ÏÂÌáÈ¡messageÓÐЧÊý¾ÝµÄ´úÂë¡£
ʹÓÃÃüÁî python TestOutput.py messages.pickle
Éú³ÉµÄtest.log¾ÍÊÇ»ñµÃµÄÓÐЧÊý¾Ý
·µ»ØÊý¾ÝµÄʾÀý
1252985727.66 recei ......
# 004
# ÀûÓÃÈýÒýºÅ(''' or """)¿ÉÒÔָʾ¶àÐÐ×Ö·û´®
print '''line1
line2
line3'''
# ÁíÍ⣬Ä㻹¿ÉÒÔÔÚÈýÒýºÅÖÐÈÎÒâʹÓõ¥ÒýºÅºÍË«ÒýºÅ
print ''' "What's up? ," he replied.'''
# ·ñÔò£¬ÄãºÃʹÓÃתÒå·ûÀ´ÊµÏÖͬÑùµÄЧ¹û
# »¹ÊÇʹÓÃÈýÒýºÅºÃ£¬²»È»¾ÍÆÆ»µÁËÊÓ¾õÃÀÁË
print ' \"Wha ......