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

Python±Ê¼Ç£¨8£©

PythonµÄÃæÏò¶ÔÏóÐÔÖÊ
ÀàºÍ¶ÔÏóÊÇÃæÏò¶ÔÏó±à³ÌµÄÁ½¸öÖ÷Òª·½Ãæ¡£Àà´´½¨Ò»¸öÐÂÀàÐÍ£¬¶ø¶ÔÏóÕâ¸öÀàµÄ ʵÀý ¡£ÕâÀàËÆÓÚÄãÓÐÒ»¸öintÀàÐ͵ıäÁ¿£¬Õâ´æ´¢ÕûÊýµÄ±äÁ¿ÊÇintÀàµÄʵÀý£¨¶ÔÏ󣩡£
 
ÐèҪעÒâµÄÊÇ£¬ÔÚPythonÖУ¬¼´±ãÊÇÕûÊýÒ²±»×÷Ϊ¶ÔÏó£¨ÊôÓÚintÀࣩ¡£ÕâºÍC++¡¢Java£¨1.5°æ֮ǰ£©°ÑÕûÊý´¿´â×÷ΪÀàÐÍÊDz»Í¬µÄ¡£Í¨¹ýhelp(int)Á˽â¸ü¶àÕâ¸öÀàµÄÏêÇé¡£
 
¶ÔÏó¿ÉÒÔʹÓÃÆÕͨµÄÊôÓÚ¶ÔÏóµÄ±äÁ¿´æ´¢Êý¾Ý¡£ÊôÓÚÒ»¸ö¶ÔÏó»òÀàµÄ±äÁ¿±»³ÆΪÓò¡£¶ÔÏóÒ²¿ÉÒÔʹÓÃÊôÓÚÀàµÄº¯ÊýÀ´¾ßÓй¦ÄÜ¡£ÕâÑùµÄº¯Êý±»³ÆΪÀàµÄ·½·¨¡£ÕâЩÊõÓï°ïÖúÎÒÃÇ°ÑËüÃÇÓë¹ÂÁ¢µÄº¯ÊýºÍ±äÁ¿Çø·Ö¿ªÀ´¡£ÓòºÍ·½·¨¿ÉÒԺϳÆΪÀàµÄÊôÐÔ¡£
 
 Ò».PythonµÄ__init__·½·¨
ÀýÈç:
#!/usr/bin/python
# Filename: class_init.py
class Person:
def __init__(self, name):
self.name = name
def sayHi(self):
print 'Hello, my name is', self.name
p = Person('Swaroop')
p.sayHi()
# This short example can also be written as Person('Swaroop').sayHi()

Êä³öΪ:
$ python class_init.py
Hello, my name is Swaroop

ÔÚÒ»¶¨³Ì¶ÈÉÏ£¬¿ÉÒÔÈ϶¨ÎªPythonÖеĹ¹Ô캯Êý¡£
Èçͬ__init__·½·¨Ò»Ñù£¬»¹ÓÐÒ»¸öÌØÊâµÄ·½·¨__del__£¬ÀàËÆÓÚÎö¹¹º¯Êý.
 
×¢Òâ:PythonÖÐËùÓеÄÀà³ÉÔ±£¨°üÀ¨Êý¾Ý³ÉÔ±£©¶¼Êǹ«¹²µÄ£¬ËùÓеķ½·¨¶¼ÊÇÓÐЧµÄ¡£
Ö»ÓÐÒ»¸öÀýÍ⣺Èç¹ûÄãʹÓõÄÊý¾Ý³ÉÔ±Ãû³ÆÒÔ Ë«Ï»®Ïßǰ׺ ±ÈÈç__privatevar£¬PythonµÄÃû³Æ¹ÜÀíÌåϵ»áÓÐЧµØ°ÑËü×÷Ϊ˽ÓбäÁ¿¡£
ÕâÑù¾ÍÓÐÒ»¸ö¹ßÀý£¬Èç¹ûij¸ö±äÁ¿Ö»ÏëÔÚÀà»ò¶ÔÏóÖÐʹÓ㬾ÍÓ¦¸ÃÒÔµ¥Ï»®Ïßǰ׺¡£¶øÆäËûµÄÃû³Æ¶¼½«×÷Ϊ¹«¹²µÄ£¬¿ÉÒÔ±»ÆäËûÀà/¶ÔÏóʹÓ᣼ÇסÕâÖ»ÊÇÒ»¸ö¹ßÀý£¬²¢²»ÊÇPythonËùÒªÇóµÄ£¨ÓëË«Ï»®Ïßǰ׺²»Í¬£©¡£
 
 
 
 
¶þ.ÀàµÄ¼Ì³Ð
#!/usr/bin/python
# Filename: inherit.py
class SchoolMember:
'''Represents any school member.'''
def __init__(self, name, age):
self.name = name
self.age = age
print '(Initialized SchoolMember: %s)' % self.name
def tell(self):
'''Tell my details.'''
print 'Name:"%s" Age:"%s"' % (self.name, self.age),
class Teacher(SchoolMember):
'''Represents a teacher.'''
def __init__(self, name, age, salary):
Sc


Ïà¹ØÎĵµ£º

(ת) pythonÓ¦ÓÃÁìÓò½éÉÜ

#---------------------תתתתתתתתתתתתתתתתתתתתתתת-------------------------------------------#
Python×÷ΪһÖÖ¹¦ÄÜÇ¿´óÇÒͨÓõıà³ÌÓïÑÔ¶ø¹ãÊܺÃÆÀ£¬Ëü¾ßÓзdz£ÇåÎúµÄÓï·¨Ìص㣬ÊÊÓÃÓÚ¶àÖÖ²Ù×÷ϵͳ£¬Ä¿Ç°ÔÚ¹ú¼ÊÉϷdz£Á÷ÐУ¬ÕýÔڵõ½Ô½À´Ô½¶àµÄÓ¦Óá£
 
¡¡¡¡ÏÂÃæ¾ÍÈÃÎÒÃÇÒ»ÆðÀ´¿´¿´ËüµÄÇ¿´ó ......

Python¿âÏê½âÖ®ÍøÂç(1)

¸Õ¸ÕдÍêPythonǶÈ벿·ÖµÄ¼òµ¥Àý×Ó£¨²î²»¶à¹»ÏÖÔÚÓõÄÀ²~£©£¬½Ó×Å¿´µãʵ¼ÊµÄ¶«Î÷£¬Èç¹ûûÓÐÕâЩӦÓõĻ°£¬Ç°ÃæµÄǶÈëҲûÓÐʲôÒâÒ塣ǶÈëµÄÆäËû²¿·ÖÒÔºóÓöµ½ÔÙд£¬²»±ØÒ»ÏÂ×Ó°ÑÄÇЩº¯Êý¶¼Åª¶®£¬ÊÇ°É~
OK£¬À´¿´Python¿âÖÐÎÒÈÏΪ×îºÃÍæµÄÒ»²¿·Ö£¬Ò²¾ÍÊÇPython¶ÔÍøÒ³µÄ²Ù×÷¡£
Õâƪ¼òµ¥ËµÏÂÈçºÎͨ¹ýÍøÖ·ÏÂÔØÍøÒ³£¬Ç°ÌᵱȻÊÇ ......

pythonÖеÄÒ»¸öºÃÓõÄÎļþÃû²Ù×÷Ä£¿églob

  ѧϰpython±¾¾ÍÊÇÒµÓàÖ®ºÃ£¡Ê鱾ɶµÄ£¬¶¼ÎÞ´Ó˵Æð¡£ËùÒÔż¶ûÅöµ½Ò»¸öºÃµÄÄ£¿é£¬¾ÍÒªÔÚ²©¿ÍÖмǼһÏ£¬ÒÔ±ãÈÕºóÖ®Óá£ÊÇÒÔ¸ßÊÖÖ±½ÓµÄÆ®¹ý¡£ÏÂÃæÇÐÈëÕýÌâ¡£
  globÊÇpython×Ô¼º´øµÄÒ»¸öÎļþ²Ù×÷Ïà¹ØÄ£¿é£¬ÄÚÈÝÒ²²»¶à£¬ÓÃËü¿ÉÒÔ²éÕÒ·ûºÏ×Ô¼ºÄ¿µÄµÄÎļþ£¬¾ÍÀàËÆÓÚWindowsϵÄÎļþËÑË÷£¬¶øÇÒÒ²Ö§³ÖͨÅä·û£¬*,?,[]Õ ......

Python: ʹÓÃ×°ÊÎÆ÷¡°@¡±È¡µÃº¯ÊýÖ´ÐÐʱ¼ä

¡¡¡¡PythonÖпÉÒÔʹÓÃ×°ÊÎÆ÷¶Ôº¯Êý½øÐÐ×°ÊΣ¨»ò˵°ü×°£©£¬ÀûÓÃÕâ¸öÌØÐÔ£¬¿ÉÒԺܷ½±ã¡¢¼ò½àµØ½â¾öһЩÎÊÌ⣬±ÈÈç»ñµÃº¯ÊýÖ´ÐÐʱ¼äµÄÎÊÌâ¡£
¡¡¡¡Ê×ÏÈ£¬ÎÒÃǶ¨ÒåÒ»¸öº¯Êý£¬ÈçÏ£º
¡¡¡¡def exeTime(func):
def newFunc(*args, **args2):
t0 = time.time()
print "@%s, {%s} start" % (time.strftime("%X", time.local ......

Python±Ê¼Ç£¨7£©

  Ò»¸öPython½Å±¾µÄ¿ª·¢È«¹ý³Ì
ÎÊÌ⣺Íê³ÉÒ»¸ö¿ÉÒÔΪÎÒÃÇËùÓеÄÖØÒª³ÌÐò×ö±¸·ÝµÄ³ÌÐò¡£
²½Öè²ð½â£º
ÐèÒª±¸·ÝµÄÎļþºÍĿ¼ÓÉÒ»¸öÁбíÖ¸¶¨¡£
Îļþ±¸·Ý³ÉÒ»¸özipÎļþ¡£
zip´æµµµÄÃû³ÆÊǵ±Ç°µÄÈÕÆÚºÍʱ¼ä¡£
ÎÒÃÇʹÓñê×¼µÄzipÃüÁËüͨ³£Ä¬ÈϵØËæLinux/Unix·¢ÐаæÌṩ¡£WindowsÓû§¿ÉÒÔʹÓÃInfo-Zip³ÌÐò¡£×¢Òâ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ