[ Level 2] How to dump object to file in Python
#!/bin/env python
import os, sys
import marshal
a = [1,2,3]
fd = open('/tmp/t.log', 'wb')
marshal.dump(a, fd)
fd.close()
fd = open('/tmp/t.log', 'rb')
b = marshal.load(fd)
for i in b:
print i
fd.close()
Wish this helps. regards,
Stanley Huang
Comments
Post a Comment