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

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.'''
self.name = name
print '(Initializing %s)' % self.name
Person.population += 1
def __del__(self):
'''I am dying'''
print '%s syas bye.' % self.name
Person.population -= 1
if Person.population == 0:
print 'I am the last one.'
else:
print 'There are still %d people left.' % \
Person.population
def sayHi(self):
'''Greeting by the person.
Really, that's all it does'''
print 'Hi, my name is %s.' % self.name
def howMany(self):
'''Prints the current population'''
if Person.population == 1:
print "I am the only person here"
else:
print 'We have %d persons here.' % Person.population
luolei = Person('luolei')
luolei.sayHi()
luolei.howMany()
xiaoming = Person('Xiao Ming')
xiaoming.sayHi()
xiaoming.howMany()
luolei.sayHi()
luolei.howMany() 
PersonÔÚ¶ÔÏóÎö¹¹Ö®Ç°ÏÈÎö¹¹ÁË£¬ÔÚ¶ÔÏóÎö¹¹µÄʱºòÕÒ²»µ½ÀàµÄ˵Ã÷ÁË¡£
±ÜÃâÕâ¸öbugµÄ°ì·¨ÊÇÔÚluoleiÇ°Ãæ¼ÓÉÏÒ»¸ö_£¬¼´±ä³É_luoleiÔòûÓÐÎÊÌ⣬ÒòΪpython»áÏÈÎö¹¹Ç°ÃæÓÐÏ»®ÏߵıäÁ¿£¬Èç´ËNBµÄPython¾ÓÈ»ÓÐÕâô¸öÃ÷ÏÔµÄÎÊÌ⣬À§»ó
PythonµÄ°æ±¾£ºPython 2.6.4


Ïà¹ØÎĵµ£º

PythonÄÚ²¿µÄÏß³ÌʵÏÖ

ÔÚPythonÖеÄÏß³ÌÔËÐÐʵ¼ÊÊÇÊܵ½InterpreterµÄ¿ØÖÆ»òÕßËµÇ£ÖÆµÄ¡£ÔÚInterpreterµÄºËÐĺ¯Êý
PyObject * PyEval_EvalFrameEx
(PyFrameObject *f, int
throwflag)
ÎÒÃÇ¿ÉÒÔ¿´µ½ÓÐÒ»¸öÈ«¾Ö±äÁ¿_Py_TickerÀ´¿ØÖÆ×ÅÏ̶߳ÔInterpreterµÄÕ¼Óеģ¬Ä¬ÈÏÊÇInterpreterÿִÐÐÒ»°ÙÌõÖ¸Áî¾Í»áÊÍ·ÅÁíÒ»¸öÈ«¾Ö±äÁ¿interpreter_lock.
......

¹ØÓÚPythonÕýÔò±í´ïʽµÄÇø·Ö´óСдµÄÎÊÌâ

×î½üÔÚÓÃPython´¦ÀíһЩÊý¾Ý£¬Êý¾ÝÐèÒª´æ´¢µ½MySQLÊý¾Ý¿âÖУ¬²ÉÓÃMySQLdbÀ´½øÐÐÊý¾Ý¿âµÄ²Ù×÷£¬µ«ÊDZ»Ò»¸öÎÊÌâÀ§ÈÅÁ˺ܾá£ÔÚ´ò¿ªÊý¾Ý¿âµÄʱºòMySQLdb.connect(self.host, self.user, self.password, self.database, port=self.port)³öÒì³££¬¶øÇÒÒì³£³öÏÖµÄλÖ÷dz£Ææ¹Ö¡£
³öÏÖÔÚconverters.py 164ÐÐ
from decimal import ......

python joinµÄÓ÷¨

>>> a="abcd"
>>> ",".join(a)
'a,b,c,d'
>>> "|".join(['a','b','c'])
'a|b|c'
>>> ",".join(('a','b','c'))
'a,b,c'
>>> ",".join({'a':1,'b':2,'c':3})
'a,c,b' ......

Python½âÊÍÖ´ÐÐÔ­Àí

̸µ½ÁËPythonÓï¾äµÄÁ½ÖÖÖ´Ðз½Ê½£¬Êµ¼ÊÉÏ£¬ÕâÁ½ÖÖÔËÐз½Ê½ÔÚ±¾ÖÊ ÉÏÊÇÏàͬµÄ£¬ËüÃǶ¼ÊÇÓɽâÊÍÆ÷À´½âÊÍÖ´ÐÐÎÒÃÇÌṩµÄPythonÓï¾ä¡£ ÕâÀïËù˵µÄ½âÊÍÖ´ÐÐÊÇÏà¶ÔÓÚ±àÒëÖ´ÐжøÑԵġ£ÎÒÃÇÖªµÀ£¬Ê¹ÓÃÖîÈç C»òC++Ö®ÀàµÄ±àÒëÐÔÓïÑÔ±àдµÄ³ÌÐò¿ÉÒÔ´ÓÔ´Îļþת»»³É¼ÆËã»úʹÓà µÄ»úÆ÷ÓïÑÔ£¬ ¾­Á¬½ÓÆ÷Á¬½ÓºóÐγɶþ½øÖÆ¿ÉÖ´ÐÐÎļþ¡£µ±ÎÒÃÇÔ ......

Python×Ö·û´®²Ù×÷[ת]


Python×Ö·û´®²Ù×÷
pythonÈçºÎÅжÏÒ»¸ö×Ö·û´®Ö»°üº¬Êý×Ö×Ö·û 
python ×Ö·û´®±È½Ï 
ÏÂÃæÁгöÁ˳£ÓõÄpythonʵÏÖµÄ×Ö·û´®²Ù×÷
1.¸´ÖÆ×Ö·û´®
#strcpy(sStr1,sStr2)
sStr1 = 'strcpy'
sStr2 = sStr1
sStr1 = 'strcpy2'
print sStr2
2.Á¬½Ó×Ö·û´®
#strcat(sStr1,sStr2)
sStr1 = 'strcat'
sStr2 = 'appen ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ