Aulas Python Aulas Python - 079 - Armazenamento de Dados V: shelve
Aulas Python - 079 - Armazenamento de Dados V: shelve Transcript and Lesson Notes
1) import shelve 2) file = shelve.open(filename) -- abre ou cria um novo db 3) file[key] = value -- guarda um valor na chave 4) value = file[key] -- recebe valor da chave 5) count = len(file) -- número de chaves 6) index
Quick Summary
1) import shelve 2) file = shelve.open(filename) -- abre ou cria um novo db 3) file[key] = value -- guarda um valor na chave 4) value = file[key] -- recebe valor da chave 5) count = len(file) -- número de chaves 6) index
Key Takeaways
- Review the core idea: 1) import shelve 2) file = shelve.open(filename) -- abre ou cria um novo db 3) file[key] = value -- guarda um valor na chave 4) value = file[key] -- recebe valor da chave 5) count = len(file) -- número de chaves 6) index
- Understand how Python fits into Aulas Python - 079 - Armazenamento de Dados V: shelve.
- Understand how Aulas fits into Aulas Python - 079 - Armazenamento de Dados V: shelve.
- Understand how Curso fits into Aulas Python - 079 - Armazenamento de Dados V: shelve.
- Understand how Software fits into Aulas Python - 079 - Armazenamento de Dados V: shelve.
Key Concepts
Full Transcript
1) import shelve 2) file = shelve.open(filename) -- abre ou cria um novo db 3) file[key] = value -- guarda um valor na chave 4) value = file[key] -- recebe valor da chave 5) count = len(file) -- número de chaves 6) index = file.keys() -- coloca os valores das chaves numa lista 7) found = key in file 8) del file[key] 9) for key in file 10) file.close() 11) file[key] = list 12) file[key].append(element) -- list permanece nao modificada 13) temp = file[key] - temp.append(element) - file[key] = temp 14) file = shelve.open(filename, writeback = True) permite que os objetos sejam modificaveis pois todos estão armazenados temporariamente na memória, mas torna o programa mais lento Bibliografia Sites: http://docs.python.org/3.4/library/shelve.html pymotw.com/2/shelve/ python.about.com/od/pythonstandardlibrary/a/shelve_intro.htm Livros: Beginning python from novice to professional - Cap. 10, The Standard Library: A Few Favorites, shelve Aprendendo Python - 848 a 853 Programming Python - 1316 a 1323 Dropbox: https://www.dropbox.com/sh/t0lvoxb2fxfhctx/AABIYnYyvqPby6oq0NkQWpRaa
Lesson FAQs
What is Aulas Python - 079 - Armazenamento de Dados V: shelve about?
1) import shelve 2) file = shelve.open(filename) -- abre ou cria um novo db 3) file[key] = value -- guarda um valor na chave 4) value = file[key] -- recebe valor da chave 5) count = len(file) -- número de chaves 6) index
What key concepts are covered in this lesson?
The lesson covers Python, Aulas, Curso, Software, Programação.
What should I learn before Aulas Python - 079 - Armazenamento de Dados V: shelve?
Review the previous lessons in Aulas Python, then use the transcript and key concepts on this page to fill any gaps.
How can I practice after this lesson?
Practice by applying the main concepts: Python, Aulas, Curso, Software.
Does this lesson include a transcript?
Yes. The full transcript is visible on this page in indexable HTML sections.
Is this lesson free?
Yes. CourseHive lessons and courses are available to learn online for free.
