代码片段如下:
----ship----
else:
print u"failure"
write()
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----