<br />
<b>Warning</b>:  Undefined array key "global_protection_id" in <b>/home/wikitechy/public_html/interview-questions/wp-content/plugins/content-protector/inc/class-ps-rest-handler.php</b> on line <b>51</b><br />
{"id":874,"date":"2021-07-18T14:43:49","date_gmt":"2021-07-18T14:43:49","guid":{"rendered":"https:\/\/www.wikitechy.com\/interview-questions\/?p=874"},"modified":"2021-09-09T11:11:25","modified_gmt":"2021-09-09T11:11:25","slug":"what-is-python-pickle-module","status":"publish","type":"post","link":"https:\/\/www.wikitechy.com\/interview-questions\/python\/what-is-python-pickle-module\/","title":{"rendered":"What is Python Pickle Module ?"},"content":{"rendered":"<div class=\"TextHeading\">\n<div class=\"hddn\">\n<h2 id=\"python-pickle-module\" class=\"color-purple\" style=\"text-align: justify;\">Python Pickle Module<\/h2>\n<\/div>\n<\/div>\n<div class=\"Content\" style=\"text-align: justify;\">\n<div class=\"hddn\">\n<ul>\n<li>Python&#8217;s pickle module is a serialization (converting the object into streams of bytes) library which is used to serialize the python objects.That means it can be used to encode and decode your functions, classes, dict, list, string etc,.<\/li>\n<li>Two important methods that pickle module provides are\u00a0<code>`pickle.dumps`<\/code>\u00a0and\u00a0<code>`pickle.loads`<\/code>.<\/li>\n<\/ul>\n<\/div>\n<\/div>\n<div class=\"text-center row\" style=\"text-align: justify;\"><\/div>\n<div class=\"TextHeading\" style=\"text-align: justify;\">\n<div class=\"hddn\">\n<h2 id=\"what-is-pickle-in-python-used-for\" class=\"color-purple\">What is pickle in python used for ?<\/h2>\n<\/div>\n<\/div>\n<div class=\"Content\" style=\"text-align: justify;\">\n<div class=\"hddn\">\n<ul>\n<li>It is used for serializing and de-serializing a Python object structure. Any object in python can be pickled so that it can be saved on disk.<\/li>\n<li>What pickle does \u201cserialises\u201d the object before writing the file. Pickling is a way to convert a python object (list, dict, etc.) into a character stream.<\/li>\n<\/ul>\n<\/div>\n<\/div>\n<div class=\"TextHeading\" style=\"text-align: justify;\">\n<div class=\"hddn\">\n<h2 id=\"pickle-dump-example\" class=\"color-purple\">Pickle dump Example:<\/h2>\n<\/div>\n<\/div>\n<div class=\"CodeContent\" style=\"text-align: justify;\">\n<div class=\"hddn\">\n<figure class=\"highlight\">\n<pre><code id=\"code1\" class=\"python hljs bash\" data-lang=\"python\"><span class=\"nt\"><span class=\"hljs-comment\"># Save a dictionary into a pickle file.<\/span>\r\nimport pickle    \r\nwikitechy_tutorial = { <span class=\"hljs-string\">\"Technology1\"<\/span>: <span class=\"hljs-string\">\"python\"<\/span>, <span class=\"hljs-string\">\"Technology2\"<\/span>: <span class=\"hljs-string\">\"java\"<\/span> }    \r\npickle.dump( wikitechy_tutorial, open( <span class=\"hljs-string\">\"save.p\"<\/span>, <span class=\"hljs-string\">\"wb\"<\/span> ) )<\/span><\/code><\/pre>\n<\/figure>\n<\/div>\n<\/div>\n<div class=\"TextHeading\" style=\"text-align: justify;\">\n<div class=\"hddn\">\n<h2 id=\"pickle-load-example\" class=\"color-purple\">Pickle Load Example:<\/h2>\n<\/div>\n<\/div>\n<div class=\"CodeContent\" style=\"text-align: justify;\">\n<div class=\"hddn\">\n<figure class=\"highlight\">\n<pre><code id=\"code2\" class=\"python hljs typescript\" data-lang=\"python\"><span class=\"nt\"># Load the dictionary back from the pickle file.\r\n<span class=\"hljs-keyword\">import<\/span> pickle    \r\nwikitechy_tutorial = pickle.load( open( <span class=\"hljs-string\">\"save.p\"<\/span>, <span class=\"hljs-string\">\"rb\"<\/span> ) )\r\n# wikitechy_tutorial is now { <span class=\"hljs-string\">\"Technology1\"<\/span>: <span class=\"hljs-string\">\"python\"<\/span>, <span class=\"hljs-string\">\"Technology2\"<\/span>: <span class=\"hljs-string\">\"java\"<\/span> }<\/span><\/code><\/pre>\n<\/figure>\n<\/div>\n<\/div>\n<div style=\"text-align: justify;\">\n<div id=\"bsa-zone_1590522394795-6_123456\"><\/div>\n<\/div>\n<div class=\"hddn\"><img fetchpriority=\"high\" decoding=\"async\" class=\"alignnone size-medium aligncenter\" src=\"https:\/\/cdn.wikitechy.com\/interview-questions\/python\/what-is-python-pickle-module.png\" alt=\"what is python pickle module\" width=\"425\" height=\"539\" \/><\/div>\n","protected":false},"excerpt":{"rendered":"<p>Answer : Python&#8217;s pickle module is a serialization (converting the object into streams of bytes) library which is used to serialize the python objects.<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"passster_activate_protection":false,"passster_protect_child_pages":"","passster_protection_type":"password","passster_password":"","passster_activate_overwrite_defaults":"","passster_headline":"","passster_instruction":"","passster_placeholder":"","passster_button":"","passster_id":"","passster_activate_misc_settings":"","passster_redirect_url":"","passster_hide":"no","passster_area_shortcode":"","gtb_hide_title":false,"gtb_wrap_title":false,"gtb_class_title":"","gtb_remove_headerfooter":false,"footnotes":""},"categories":[5608],"tags":[195,491,360,203,199,214,198,209,205,222,484,196,212,213,5801,286,710,207,366,204,217,282,5792,5788,5793,5794,5789,208,5620,5790,5617,5791,5797,5800,5787,5798,5799,5796,5619,5618,483,206,200,197,5795,280,364,5802,5631],"class_list":["post-874","post","type-post","status-publish","format-standard","hentry","category-python","tag-accenture-interview-questions-and-answers","tag-applied-materials-interview-questions-and-answers","tag-atos-interview-questions-and-answers","tag-capgemini-interview-questions-and-answers","tag-casting-networks-india-pvt-limited-interview-questions-and-answers","tag-cgi-group-inc-interview-questions-and-answers","tag-chetu-interview-questions-and-answers","tag-collabera-technologies-interview-questions-and-answers","tag-dell-international-services-india-pvt-ltd-interview-questions-and-answers","tag-flipkart-interview-questions-and-answers","tag-genpact-interview-questions-and-answers","tag-ibm-interview-questions-and-answers","tag-indecomm-global-services-interview-questions-and-answers","tag-infosys-technologies-interview-questions-and-answers","tag-install-pickle-python","tag-lt-infotech-interview-questions-and-answers","tag-mavenir-interview-questions-and-answers","tag-mphasis-interview-questions-and-answers","tag-netapp-interview-questions-and-answers","tag-oracle-corporation-interview-questions-and-answers","tag-peoplestrong-interview-questions-and-answers","tag-persistent-systems-interview-questions-and-answers","tag-pickle-dump-multiple-objects","tag-pickle-file-extension","tag-pickle-ran-out-of-inputc","tag-pickle-vs-pickle","tag-pip-install-pickle","tag-prokarma-softech-pvt-ltd-interview-questions-and-answers","tag-python-data-science-interview-questions","tag-python-dill","tag-python-interview-questions-and-answers-for-testers","tag-python-pickle-create-new-file","tag-python-pickle-dump","tag-python-pickle-dump-example","tag-python-pickle-example","tag-python-pickle-file","tag-python-pickle-module","tag-python-pickle-tutorial","tag-python-programming-questions","tag-python-telephonic-interview-questions","tag-reliance-industries-ltd-interview-questions-and-answers","tag-sap-labs-india-pvt-ltd-interview-questions-and-answers","tag-tech-mahindra-interview-questions-and-answers","tag-unitedhealth-group-interview-questions-and-answers","tag-unpickle-python","tag-virtusa-consulting-services-pvt-ltd-interview-questions-and-answers","tag-wells-fargo-interview-questions-and-answers","tag-what-is-pickle-in-python","tag-xoriant-soluti-interview-questions-and-answers"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v22.6 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>What is Python Pickle Module ? - Python Programming Questions<\/title>\n<meta name=\"description\" content=\"What is Python Pickle Module ? - python programming questions ? - Python&#039;s pickle module is a serialization (converting the object into streams of bytes) library\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.wikitechy.com\/interview-questions\/python\/what-is-python-pickle-module\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"What is Python Pickle Module ? - Python Programming Questions\" \/>\n<meta property=\"og:description\" content=\"What is Python Pickle Module ? - python programming questions ? - Python&#039;s pickle module is a serialization (converting the object into streams of bytes) library\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wikitechy.com\/interview-questions\/python\/what-is-python-pickle-module\/\" \/>\n<meta property=\"og:site_name\" content=\"Wikitechy\" \/>\n<meta property=\"article:published_time\" content=\"2021-07-18T14:43:49+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2021-09-09T11:11:25+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/cdn.wikitechy.com\/interview-questions\/python\/what-is-python-pickle-module.png\" \/>\n<meta name=\"author\" content=\"Editor\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Editor\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wikitechy.com\/interview-questions\/python\/what-is-python-pickle-module\/\",\"url\":\"https:\/\/www.wikitechy.com\/interview-questions\/python\/what-is-python-pickle-module\/\",\"name\":\"What is Python Pickle Module ? - Python Programming Questions\",\"isPartOf\":{\"@id\":\"https:\/\/www.wikitechy.com\/interview-questions\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.wikitechy.com\/interview-questions\/python\/what-is-python-pickle-module\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.wikitechy.com\/interview-questions\/python\/what-is-python-pickle-module\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/cdn.wikitechy.com\/interview-questions\/python\/what-is-python-pickle-module.png\",\"datePublished\":\"2021-07-18T14:43:49+00:00\",\"dateModified\":\"2021-09-09T11:11:25+00:00\",\"author\":{\"@id\":\"https:\/\/www.wikitechy.com\/interview-questions\/#\/schema\/person\/4d5a581fb5470d1560324bddc5e8b757\"},\"description\":\"What is Python Pickle Module ? - python programming questions ? - Python's pickle module is a serialization (converting the object into streams of bytes) library\",\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wikitechy.com\/interview-questions\/python\/what-is-python-pickle-module\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.wikitechy.com\/interview-questions\/python\/what-is-python-pickle-module\/#primaryimage\",\"url\":\"https:\/\/cdn.wikitechy.com\/interview-questions\/python\/what-is-python-pickle-module.png\",\"contentUrl\":\"https:\/\/cdn.wikitechy.com\/interview-questions\/python\/what-is-python-pickle-module.png\"},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.wikitechy.com\/interview-questions\/#website\",\"url\":\"https:\/\/www.wikitechy.com\/interview-questions\/\",\"name\":\"Wikitechy\",\"description\":\"Interview Questions\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.wikitechy.com\/interview-questions\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.wikitechy.com\/interview-questions\/#\/schema\/person\/4d5a581fb5470d1560324bddc5e8b757\",\"name\":\"Editor\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.wikitechy.com\/interview-questions\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/e9531079fe7e07841b7b156c04d65e5f39d4adfd18b6ffe3edfff8ca5aab85b5?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/e9531079fe7e07841b7b156c04d65e5f39d4adfd18b6ffe3edfff8ca5aab85b5?s=96&d=mm&r=g\",\"caption\":\"Editor\"},\"url\":\"https:\/\/www.wikitechy.com\/interview-questions\/author\/editor\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"What is Python Pickle Module ? - Python Programming Questions","description":"What is Python Pickle Module ? - python programming questions ? - Python's pickle module is a serialization (converting the object into streams of bytes) library","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.wikitechy.com\/interview-questions\/python\/what-is-python-pickle-module\/","og_locale":"en_US","og_type":"article","og_title":"What is Python Pickle Module ? - Python Programming Questions","og_description":"What is Python Pickle Module ? - python programming questions ? - Python's pickle module is a serialization (converting the object into streams of bytes) library","og_url":"https:\/\/www.wikitechy.com\/interview-questions\/python\/what-is-python-pickle-module\/","og_site_name":"Wikitechy","article_published_time":"2021-07-18T14:43:49+00:00","article_modified_time":"2021-09-09T11:11:25+00:00","og_image":[{"url":"https:\/\/cdn.wikitechy.com\/interview-questions\/python\/what-is-python-pickle-module.png"}],"author":"Editor","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Editor","Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wikitechy.com\/interview-questions\/python\/what-is-python-pickle-module\/","url":"https:\/\/www.wikitechy.com\/interview-questions\/python\/what-is-python-pickle-module\/","name":"What is Python Pickle Module ? - Python Programming Questions","isPartOf":{"@id":"https:\/\/www.wikitechy.com\/interview-questions\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.wikitechy.com\/interview-questions\/python\/what-is-python-pickle-module\/#primaryimage"},"image":{"@id":"https:\/\/www.wikitechy.com\/interview-questions\/python\/what-is-python-pickle-module\/#primaryimage"},"thumbnailUrl":"https:\/\/cdn.wikitechy.com\/interview-questions\/python\/what-is-python-pickle-module.png","datePublished":"2021-07-18T14:43:49+00:00","dateModified":"2021-09-09T11:11:25+00:00","author":{"@id":"https:\/\/www.wikitechy.com\/interview-questions\/#\/schema\/person\/4d5a581fb5470d1560324bddc5e8b757"},"description":"What is Python Pickle Module ? - python programming questions ? - Python's pickle module is a serialization (converting the object into streams of bytes) library","inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wikitechy.com\/interview-questions\/python\/what-is-python-pickle-module\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.wikitechy.com\/interview-questions\/python\/what-is-python-pickle-module\/#primaryimage","url":"https:\/\/cdn.wikitechy.com\/interview-questions\/python\/what-is-python-pickle-module.png","contentUrl":"https:\/\/cdn.wikitechy.com\/interview-questions\/python\/what-is-python-pickle-module.png"},{"@type":"WebSite","@id":"https:\/\/www.wikitechy.com\/interview-questions\/#website","url":"https:\/\/www.wikitechy.com\/interview-questions\/","name":"Wikitechy","description":"Interview Questions","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.wikitechy.com\/interview-questions\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/www.wikitechy.com\/interview-questions\/#\/schema\/person\/4d5a581fb5470d1560324bddc5e8b757","name":"Editor","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.wikitechy.com\/interview-questions\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/e9531079fe7e07841b7b156c04d65e5f39d4adfd18b6ffe3edfff8ca5aab85b5?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/e9531079fe7e07841b7b156c04d65e5f39d4adfd18b6ffe3edfff8ca5aab85b5?s=96&d=mm&r=g","caption":"Editor"},"url":"https:\/\/www.wikitechy.com\/interview-questions\/author\/editor\/"}]}},"_links":{"self":[{"href":"https:\/\/www.wikitechy.com\/interview-questions\/wp-json\/wp\/v2\/posts\/874","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wikitechy.com\/interview-questions\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wikitechy.com\/interview-questions\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wikitechy.com\/interview-questions\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wikitechy.com\/interview-questions\/wp-json\/wp\/v2\/comments?post=874"}],"version-history":[{"count":3,"href":"https:\/\/www.wikitechy.com\/interview-questions\/wp-json\/wp\/v2\/posts\/874\/revisions"}],"predecessor-version":[{"id":3231,"href":"https:\/\/www.wikitechy.com\/interview-questions\/wp-json\/wp\/v2\/posts\/874\/revisions\/3231"}],"wp:attachment":[{"href":"https:\/\/www.wikitechy.com\/interview-questions\/wp-json\/wp\/v2\/media?parent=874"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wikitechy.com\/interview-questions\/wp-json\/wp\/v2\/categories?post=874"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wikitechy.com\/interview-questions\/wp-json\/wp\/v2\/tags?post=874"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}