hab python unter ubuntu 10.04 installiert über apt-get install python.
Ich bekomme beim ausführen von meinem Testskript unten stehenden Fehler.
Muß ich noch was nachinstallieren?
Skript ist von: http://zetcode.com/tutorials/pyqt4/germ ... tprograms/
Besten Dank
heinz@pippin:~/scripte$ ./pickle.py
Monica
15
Traceback (most recent call last):
File "./pickle.py", line 5, in <module>
import pickle
File "/home/heinz/scripte/pickle.py", line 24, in <module>
pickle.dump(person, f)
AttributeError: 'module' object has no attribute 'dump'
Mein Testskript:
Code: Alles auswählen
#!/usr/bin/python
# pickle.py
import pickle
class Person:
def __init__(self, name, age):
self.name = name
self.age = age
def getName(self):
return self.name
def getAge(self):
return self.age
person = Person('Monica', 15)
print person.getName()
print person.getAge()
f = open('monica', 'w')
pickle.dump(person, f)
f.close()
f = open('monica', 'r')
monica = pickle.load(f)
f.close()
print monica.getName()
print monica.getAge()