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

python self __init__

self
ÀàµÄ·½·¨ÓëÆÕͨµÄº¯ÊýÖ»ÓÐÒ»¸öÌØ±ðµÄÇø±ð——ËüÃDZØÐëÓÐÒ»¸ö¶îÍâµÄµÚÒ»¸ö²ÎÊýÃû³Æ£¬µ«ÊÇ
ÔÚµ÷ÓÃÕâ¸ö·½·¨µÄʱºòÄ㲻ΪÕâ¸ö²ÎÊý¸³Öµ£¬Python»áÌṩÕâ¸öÖµ¡£Õâ¸öÌØ±ðµÄ±äÁ¿Ö¸¶ÔÏó±¾
Éí£¬°´ÕÕ¹ßÀýËüµÄÃû³ÆÊÇself¡£
ÕâÒ²Òâζ×ÅÈç¹ûÄãÓÐÒ»¸ö²»ÐèÒª²ÎÊýµÄ·½·¨£¬Ä㻹ÊǵøøÕâ¸ö·½·¨¶¨ÒåÒ»¸öself²ÎÊý¡£
__init__·½·¨
__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±Ê¼Ç——¹îÒìBUG£¿

×î½üÓÖÖØÐÂ×°ÉÏÁËwindows 7¸Ð¾õ»¹ÊÇÄÇÑù£¬Ö÷ÒªÊÇÏëÓÃM8SDKдЩ³ÌÐò¡£Ò²ÏëÔÚwindowsÉÏÍæÍæ£¬Ò»Ö±¶¼¾õµÃÓÃCдһЩ³£ÓõĶ«¶«ºÜ¸´ÔÓ£¬Ö»ÓнèÖúÓÚ½âÊÍÐÔÓïÑÔÁË£¬ÔÚpython, ruby¼äÑ¡Ôñ£¬×îÖÕÓÃPython¡£
pythonµÄÓï·¨·Ç³£¼òµ¥£¬¶ÔÓÚÒ»¸öѧ¹ý±à³ÌµÄÈË¿ÉÄÜÒ»ÉÏÎç¾Í²î²»¶àÁË£¬²»¹ýpythonµÄÇ¿´óÖ®´¦ÔÚÓÚËüÓÐN¶àµÄ¿â¿ÉÒÔ·½±ãÎÒÃÇ´¦ÀíÎ ......

python ÃüÁîÐвÎÊý


±¾Æª½«½éÉÜpythonÖÐsys, getoptÄ£¿é´¦ÀíÃüÁîÐвÎÊý
Èç¹ûÏë¶Ôpython½Å±¾´«²ÎÊý£¬pythonÖжÔÓ¦µÄargc, argv(cÓïÑÔµÄÃüÁîÐвÎÊý)ÊÇÊ²Ã´ÄØ£¿
ÐèҪģ¿é£ºsys
²ÎÊý¸öÊý£ºlen(sys.argv)
½Å±¾Ãû£º    sys.argv[0]
²ÎÊý1£º     sys.argv[1]
²ÎÊý2£º     sys.argv[2]
test.py
1
import ......

PythonµÄbug

PythonÌ«»ðÁË£¬²»Ñ§µã¶¼¸Ð¾õ×Ô¼º²»ÊÇѧ¼ÆËã»úµÄ£¬½ñÌì¿´Á˸ö²»´íµÄ¡¶¼òÃ÷python½Ì³Ì¡·£¬ºÜ²»´í¡£²»¹ýÔÚѧϰ¹ý³ÌÖУ¬¾ÓÈ»·¢ÏÖÁËÒ»¸öPythonµÄbug£¬
#!/usr/bin/python
#coding=UTF-8
class Person:
'''Represents a person.'''
population = 0
def __init__(self, name):
'''Initializes the person's data.'''
......

Eclipse»ùÓÚpython¡¢Django×öWeb¿ª·¢

 ÏȽ«ÉÏÃæ´´½¨ºÃµÄtestdemo¹¤³ÌĿ¼\£¬½«C:\Python25\Lib\site-packages\django\binÖеÄtestdemoĿ¼¿½±´µ½×Ô¼ºµÄ¹¤×÷Ŀ¼ÖУ¬È»ºóÆô¶¯eclipse£¬µã»÷“File”->“New”->“project…”£¬½«»á¿´µ½ÒÔÏ»­Ãæ
 
Ñ¡Ôñ“Pydev Project”£¬µã»÷“Next&rdquo ......

PythonÖ®HTMLParser

"""A parser for HTML and XHTML."""
# This file is based on sgmllib.py, but the API is slightly different.
# XXX There should be a way to distinguish between PCDATA (parsed
# character data -- the normal case), RCDATA (replaceable character
# data -- only char and entity references and end tags a ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ