Advertisement
Fhernd

guardar-objeto.py

Jan 27th, 2018
784
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.31 KB | None | 0 0
  1. import pickle
  2.  
  3. class Computador:
  4.  
  5.     def __init__(self, marca):
  6.         self.marca = marca
  7.    
  8.     def encender(self):
  9.         pass
  10.        
  11.     def apagar(self):
  12.         pass
  13.        
  14.     def obtener_marca(self):
  15.         return self.marca
  16.        
  17.  
  18. archivo = open('computador.pickle', 'wb')
  19.  
  20. laptop = Computador('Asus')
  21.  
  22. pickle.dump(laptop, archivo)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement