PythonÈëÃŵÄ36¸öÀý×Ó Ö® 19
Ô´´úÂëÏÂÔØ£ºÏÂÔØµØÖ·ÔÚÕâÀï
# 023
# Tuple(ÔªËØ×é)ÊDz»¿É±äµÄÁбí
tuple1 = (1, 2, 3)
print tuple1
tuple2 = (tuple1, 4, 5, 6) # Ò»¸öÔªËØ×é¿ÉÒÔ×÷ΪÁíÍâÒ»¸öÔªËØ×éµÄÔªËØ
print tuple2 # ²¢ÇÒÄܹ»ÔÚ´æ´¢µÄʱºò±£³ÖÔʼµÄÂß¼¹ØÏµ
for ele in tuple2:
print ele
print '\n'
for ele in tuple2[0]:
print ele
print '\n'
# ÔªËØ×éÓë¸ñʽ»¯Êä³ö
age = 22
name = 'Ning'
print '%s is %d years old.' % (name, age)
print 'Hello, %s' % name # Ò»¸öÔªËØµÄʱºò¿ÉÒÔ²»ÓÃÔªËØ×é
(1, 2, 3)
((1, 2, 3), 4, 5, 6)
(1, 2, 3)
4
5
6
1
2
3
Ning is 22 years old.
Hello, Ning
Ïà¹ØÎĵµ£º
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 ......
# 015
# ĬÈϲÎÊýµÄ±¾ÖÊÊÇ:
# ²»ÂÛÄãÊÇ·ñÌṩ¸øÎÒÕâ¸ö²ÎÊý,ÎÒ¶¼ÊÇÒªÓÃËü,
# ÄÇôÎÒ¾ÍÒªÏëºÃÔÚÄã²»ÏòÎÒÌṩ²ÎÊýµÄʱºòÎÒ¸ÃʹÓÃʲô¡£
# »òÕߣ¬ÕâÑùÀ´Àí½â£º
# ÓÐһЩ²ÎÊýÔÚÒ»°ãÇé¿öÏÂÊÇÔ¼¶¨Ë׳ɵģ¬
# µ«£¬ÔÚ¼«ÉÙÇé¿öÏ»áÓÐһЩºÜÓиöÐÔµÄÈË»á´òÆÆ´«Í³¶ø°´ÕÕ×Ô¼ºµÄϰ¹ßÀ´×öÊÂ
def theFirstDayInAWeek(theDay = 'Sunda ......
# 017
def lifeIsAMirror():
string = raw_input()
if string == 'I love you!':
return 'I love you, too!'
elif string == 'Fuck you!':
return ''
else:
return
# end of def
string = lifeIsAMirror()
if len(string) == 0:
print 'You have nothing.'
else: ......
Àý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
_ ......