{"id":8465,"date":"2023-11-08T18:35:10","date_gmt":"2023-11-08T13:05:10","guid":{"rendered":"https:\/\/python-programs.com\/?p=8465"},"modified":"2023-11-10T12:22:30","modified_gmt":"2023-11-10T06:52:30","slug":"python-data-persistence-plistlib-module","status":"publish","type":"post","link":"https:\/\/python-programs.com\/python-data-persistence-plistlib-module\/","title":{"rendered":"Python Data Persistence – plistlib Module"},"content":{"rendered":"
Lastly, we have a look at plist module that used to read and write \u2018property list\u2019 files (they usually have .plist\u2019 extension). This type of file is mainly used by MAC OS X. These files are essentially XML documents, typically used to store and retrieves properties of an object.
\nThe functionality of plastic module is more or less similar to other serialization libraries. It defines dumps () and loads () functions for the string representation of Python objects. The load () and dump () functions read and write plist disk files.
\nThe following script stores a diet object to a plist file.<\/p>\n
Example<\/strong><\/p>\n The load() function retrieves an identical dictionary object from the file.<\/p>\n Example<\/strong><\/p>\n Another important data persistence library in Python is the sqlite3 module. It deals with read\/write operations on the SQLite relational database. Before we explore its functionality, let us get acquainted with RDBMS concepts and the basics of SQL, which is the next chapter.<\/p>\n","protected":false},"excerpt":{"rendered":" Python Data Persistence – plistlib Module Lastly, we have a look at plist module that used to read and write \u2018property list\u2019 files (they usually have .plist\u2019 extension). This type of file is mainly used by MAC OS X. These files are essentially XML documents, typically used to store and retrieves properties of an object. …<\/p>\nimport plistlib\r\nproplist = {\r\n\"name\" : \"Ramesh\",\r\n\"class\":\"XII\",\r\n\"div\":\"B\",\r\n\"marks\" : {\"phy\":50, \"che\" 60, \"maths\":80}\r\n}\r\nfileName=open ('marks .plist' ' wb' )\r\nplistlib . dump (proplist, fileName)\r\nfileName . close ()<\/pre>\n
with open('marks.plist', 'rb') as fp:\r\np1 = plistlib.load(fp) \r\nprint(p1)<\/pre>\n