代碼片斷以下:ip
----ship----it
else:file
print u"failure"方法
write()path
except:
print u"Failure"
write()
def write(self):
basename = os.path.splitext(os.path.basename(__file__))[0]
----ship----
若要在同類的其餘方法中使用write,則須要在調用時,在write以前加上"self.":self.write
修改後,代碼片斷以下:
----ship----
else:
print u"failure"
self.write
except:
print u"Failure"
self.write
def write(self):
basename = os.path.splitext(os.path.basename(__file__))[0]
----ship----