• R/O
  • SSH

Tags
Aucun tag

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

File Info

Révision f2b96aabd502dccaa3318d52470959d220017cf1
Taille 672 octets
l'heure 2009-06-26 22:56:18
Auteur isella
Message de Log

I added a simple serialization example based on cpickle.

Content

#!/usr/bin/env python
import cPickle
import scipy as s
inFridge = ["ketchup", "mustard", "relish"]
print inFridge
FILE = open("fridge.txt", 'w')
cPickle.dump(inFridge, FILE)
FILE.close()

#Now I re-read the saved list into another format

FILE2 = open("fridge.txt", 'r')
inFridgeFile = cPickle.load(FILE2)
FILE2.close()
print inFridgeFile

#Bottom line: via cpickle I can actually store a list into
#a particular text file.

#The same can be achieved for a numpy array

z=s.arange(10)*s.sqrt(s.pi)


FILE = open("sci_arr.txt", 'w')
cPickle.dump(z, FILE)
FILE.close()

FILE = open("sci_arr.txt", 'r')
z2 = cPickle.load(FILE)
FILE.close()
print z2



print "So far so good"