[ 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

Popular posts from this blog

[Level 2] Shell Interactive With Zenity Episode 5 -- list

[Level 2] iif in Python