摘要:
#!/usr/bin/python# Filename: pickling.pyimport cPickle as p#import pickle as pshoplistfile = 'shoplist.data'# the name of the file where we will store 阅读全文
posted @ 2017-10-19 00:57
真勇士王小山
阅读(162)
评论(0)
推荐(0)
摘要:
首先,我们通过指明我们希望打开的文件和模式来创建一个file类的实例。模式可以为读模式('r')、写模式('w')或追加模式('a')。事实上还有多得多的模式可以使用,你可以使用help(file)来了解它们的详情。 我们首先用写模式打开文件,然后使用file类的write方法来写文件,最后我们用c 阅读全文
posted @ 2017-10-19 00:29
真勇士王小山
阅读(125)
评论(0)
推荐(0)
摘要:
#!/usr/bin/python# Filename: inherit.pyclass SchoolMember: '''Represents any school member.''' def __init__(self, name, age): self.name = name self.ag 阅读全文
posted @ 2017-10-19 00:21
真勇士王小山
阅读(99)
评论(0)
推荐(0)
摘要:
#!/usr/bin/python# Filename: objvar.pyclass Person: '''Represents a person.''' population = 0 def __init__(self, name): '''Initializes the person's da 阅读全文
posted @ 2017-10-19 00:16
真勇士王小山
阅读(144)
评论(0)
推荐(0)
摘要:
#!/usr/bin/python# Filename: class_init.pyclass Person: def __init__(self, name): self.name = name def sayHi(self): print 'Hello, my name is', self.na 阅读全文
posted @ 2017-10-19 00:09
真勇士王小山
阅读(139)
评论(0)
推荐(0)
摘要:
#!/usr/bin/python# Filename: method.pyclass Person: def sayHi(self): print 'Hello, how are you?'p = Person()p.sayHi()# This short example can also be 阅读全文
posted @ 2017-10-19 00:06
真勇士王小山
阅读(96)
评论(0)
推荐(0)