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£¬Õâô×öºÃÏñÓеã2£¬´ÕºÏÄÜÓãº
class MyClass():
def __init__(self, n = 10):
self._Field = n
def __getitem__(self, range):
return MyClass(self._Field)
obj1 = MyClass()
obj2 = obj1
obj3 = obj1[:]
obj1._Field = 100
obj4 = MyClass(123)
print obj1._Field, obj2. ......
eval(str [,globals [,locals ]])º¯Êý½«×Ö·û´®strµ±³ÉÓÐЧPython±í´ïʽÀ´ÇóÖµ£¬²¢·µ»Ø¼ÆËã½á¹û¡£
ͬÑùµØ, execÓï¾ä½«×Ö·û´®strµ±³ÉÓÐЧPython´úÂëÀ´Ö´ÐÐ.Ìṩ¸øexecµÄ´úÂëµÄÃû³Æ¿Õ¼äºÍexecÓï¾äµÄÃû³Æ¿Õ¼äÏàͬ.
×îºó£¬execfile(filename [,globals [,locals ]])º¯Êý¿ÉÒÔÓÃÀ´Ö´ÐÐÒ»¸öÎļþ,¿´ÏÂÃæµÄÀý×Ó:
>>> ev ......
Èç¹ûÄã¶ÔPython¾ØÕóתÖõÄʵ¼ÊÓ¦ÓòÙ×÷·½°¸µÄתÖò»ÖªµÀÈçºÎ½øÐÐÏÂÒ»²½Ê±£¬Äã¾ÍÄãÐèҪתÖÃÒ»¸ö¶þάÊý×é,½«Python¾ØÕóתÖõÄÐÐÁл¥»».
ÕâÑù¾Í¿ÉÒÔÍê³ÉÄãËùÐèÒªµÄÓ¦ÓòÙ×÷£¬ÒÔÏÂÊÇÎÄÕµľßÌå²Ù×÷¡£
ÄãÐèҪתÖÃÒ»¸ö¶þάÊý×é,½«ÐÐÁл¥»»£¬ÌÖÂÛ:ÄãÐèҪȷ±£¸ÃÊý×éµÄÐÐÁÐÊý¶¼ÊÇÏàͬµÄ.±ÈÈç:
arr
= [[1, 2,&nbs ......
×î½üÓÖÖØÐÂ×°ÉÏÁËwindows 7¸Ð¾õ»¹ÊÇÄÇÑù£¬Ö÷ÒªÊÇÏëÓÃM8SDKдЩ³ÌÐò¡£Ò²ÏëÔÚwindowsÉÏÍæÍæ£¬Ò»Ö±¶¼¾õµÃÓÃCдһЩ³£ÓõĶ«¶«ºÜ¸´ÔÓ£¬Ö»ÓнèÖúÓÚ½âÊÍÐÔÓïÑÔÁË£¬ÔÚpython, ruby¼äÑ¡Ôñ£¬×îÖÕÓÃPython¡£
pythonµÄÓï·¨·Ç³£¼òµ¥£¬¶ÔÓÚÒ»¸öѧ¹ý±à³ÌµÄÈË¿ÉÄÜÒ»ÉÏÎç¾Í²î²»¶àÁË£¬²»¹ýpythonµÄÇ¿´óÖ®´¦ÔÚÓÚËüÓÐN¶àµÄ¿â¿ÉÒÔ·½±ãÎÒÃÇ´¦ÀíÎ ......
# -*- coding: cp936 -*-
from email.MIMEText import MIMEText
from email.MIMEMultipart import MIMEMultipart
import smtplib
#´´½¨Ò»¸ö´ø¸½¼þµÄʵÀý
msg = MIMEMultipart()
#¹¹Ô츽¼þ
att = MIMEText(open('e:\\test.txt').read(), 'base64', 'gb2312')
att["Content-Type"] = 'application/ ......