python - Is there anyway to select and save any part of array? -
ı want select anypart of list , save while programming
so ı m looking command f.save[i:j] ;
f = open ("text.txt","w") f.write("123456789") **thats 9 bit , ı wanna selec between second , fifth bit ** = f.save[2:5]
something
you can use pickle, serializes array (and other python objects) , saves file. loads file , deserializes contents, giving off dictionary. read docs. can use 1 of it's implementations, i.e. shelve or persistent dict, supports json , other formats instead of pickle
.
you can use database sqlite or plain text file , use own implementation.
i tried pickle not working me
what not working? please give more thought question. try using shelve:
>>> import shelve >>> = [1, 2, 3, 4, 5, 6, 7, 8, 9] >>> db = shelve.open('/path/to/my/database/file.db', writeback=true) # notice file must exist >>> db['a'] = a[2:5] >>> db.close() >>> quit() # new interpreter opened >>> import shelve >>> db = shelve.open('/path/to/my/database/file.db', writeback=true) >>> db['a'] [3, 4, 5]
Comments
Post a Comment