Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

python listÖÐÌí¼ÓÀà¶ÔÏóµÄÎÊÌâ

ÔÚlistÖÐÌí¼ÓÒ»¸öÀàµÄ¾Ö²¿±äÁ¿ ÕâÑù×öÊÇ·ñºÏ·¨ Çë¿´ÏÂÃæÀý×Ó:
Python code:

class A():
def __init__( self ):
self.__a = 0
self.__b = 'hello'

def get_a( self ):
return self.__a

def get_b( self ):
return self.__b

def set_a( self, m ):
self.__a = m

def set_b( self, n ):
self.__b = n

class B():
def __init__( self ):
self.__lista = []

def fun( self ):
a = A()
print id(a)
a.set_a(10)
a.set_b("word")
self.__lista.append( a ) #½«Õâ¸öÌí¼Óµ½Ò»¸öÎÒµÄÁбíÖÐ ÊÇ·ñÕýÈ·ÄØ
a.set_a(5)
return self.__lista

if __name__ == "__main__":
b = B()
m = b.fun()
print m[0].get_a()



°´Àï˵ ÎÒ¾õµÃ"a "¼ÈÈ»ÊÇÀàBµÄ¾Ö²¿ÊµÀý»¯¶ÔÏó,ÄÇôÎÒÌí¼Óµ½listaÖеÄÓ¦¸ÃÊǸö¾Ö²¿ÊµÀý»¯¶ÔÏó,º¯Êýfun½áÊøºóÓ¦¸Ã±»×Ô¶¯Ïú»ÙÁË.¿ÉÊÇÎÒÔÚmainÖÐÒÀÈ»Äܹ»»ñµÃËüµÄÖµ. ÄѵÀÕâÑù×öÊÂÕýÈ·µÄô?Ϊʲô Çë¸÷λָ½Ì
Èç¹û²»¶Ô ÄǸÃÔõô¸ÄÄØ ¶àл
ÕýÈ·

ÕâÑùΪʲôÕýÈ·ÄØ ¾Ö²¿±äÁ¿ÎÒ¾õµÃº¯Êý½áÊøµÄʱºò²»ÊÇÓ¦¸ÃÏú»ÙÁËô..

ËüÊÇÓÐÒýÓüÆÊýµÄ£¬°ÑÖµ¸³¸øÁËm£¬ÄÇô¾ÍÔö¼ÓÁËÒ»´ÎÒýÓüÆÊý£¬ËùÒԵõÈÄã²»ÓÃmÖ®ºó²Å»áÏú»Ù¡£

Â¥ÉÏÕý½â ºÃ¶à½âÊÍÓïÑÔÊÇÕâÑùµÄ

ÉùÃ÷ÀàAºÍBµÄʱºò¿ÉÒÔ²»ÒªºóÃæµÄÀ¨ºÅ

ÒýÓÃ
ÉùÃ÷ÀàAºÍBµÄʱºò¿ÉÒÔ²»ÒªºóÃæµÄÀ¨ºÅ
<


Ïà¹ØÎÊ´ð£º

python Òì³£Í˳ö

×î½üÓÃpythonдһ¸ö³ÌÐò,×ÜÊÇÒì³£Í˳ö£¬µ«ÊÇȴû·¨ÓÃtry..exceptÀ´²¶×½

ÓÉÓÚû·¨·¢Í¼Æ¬£¬ËùÒÔ°ÑÏà¹ØµÄÐÅÏ¢´òÓ¡³öÀ´
Òì³£µÄÐÅÏ¢´óÖÂÈçÏ£º

python.exeÓöµ½ÎÊÌâÐèÒª¹Ø±Õ¡£ÎÒÃǶԴËÒýÆðµÄ²»±ã±íʾ±§Ç¸ ......

ÓÃPythonʵÏÖÒ»¸ö¼òµ¥µÄͨѶ¼

¸÷λ¸ßÊÖ£¬ÄÄλÄÜд¸ö¼òµ¥µÄͨѶ¼£¬Ö»±£´æÐÕÃûºÍÊÖ»úºÅ£¬Äܱ£´æµ½Ó²Å̲¢¿É¶Á»Ø£¬ÓÐÌí¼Ó£¬É¾³ý£¬Ð޸ģ¬²éѯ¹¦ÄÜ£¬ÃüÁîÐÐʽµÄ¾ÍÐÐ
ÕâÖÖ»îÄãµÃ×Ô¼º¸É£¬ÓÐÎÊÌâ¿ÉÒÔÎÊ£¬µ«²»»áÓÐÈË°ïÄã×öµÄ¡£

¸øÄãÔ´Âë
http://dow ......

python½Ì³ÌÖÐʹÓÃÔ´ÎļþµÄÎÊÌâ~~

ʹÓÃÔ´Îļþ

#!/usr/bin/python
# Filename : helloworld.py
print 'Hello World'

ÎÒÔõôҲ¿´²»¶®£¡Ö»ÊÇ×îºóÒ»ÐÐÎÒÖªµÀ~~Ç°ÃæÁ½ÐÐÊÇʲôÒâ˼ÄØ£¿
½Ì³ÌÉÏ˵Èç¹ûÄãʹÓÃIDLE£¬ÇëʹÓò˵ ......

[ÌáÎÊ]Python ÈçºÎºöÂÔ whitespace ¶ÁÈë

Ïñ C µÄ scanf() ÄÇÑù
±ÈÈç¶ÁÈë 1 2 3 a b c
ÿ´Î¶ÁÈëÒ»¸ö
ÏÂÃæÕâ¸öÓ¦¸ÃÊÇÄãÏëÒªµÄ°É£º
Python code:

>>> k = raw_input()
0 0123 ds dsl sd
>>> k
'0 0123 ds dsl sd'
>>> ......

³ÏÕÐPython³ÌÐòÔ±²ÎÓë¼ÆËã»úÊé¼®³ö°æ

ÓźñµÄ¸å³ê£¬³ÏÕÐPython¼¼ÊõÈËÔ±²ÎÓë¸÷ÖÖ¼¼ÊõÊé¼®³ö°æ¡£ 
ͨ¹ý¸ÃÊé¼®£¬×÷Õß¿ÉÒԵõ½Èçϱ¨³ê£º 
1¡¢·áºñµÄ¸å³ê¡£ 
2¡¢Êé¼®Öø×÷µÄÊðÃûȨ¡£ 
3¡¢¶Ô×÷ÕߺÍÊé½øÐÐÐû´«£¬Ìá¸ß×÷ÕßÔÚ¼¼ÊõȦ×ÓÀ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ