Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Pickle is not intended to be nice, but to serialize data to a file such that one can deserialize it efficiently later. Other modules, like the <a href="http://docs.python.org/3.3/library/pprint.html?highlight=prettyprint#module-pprint" rel="nofollow">PrettyPrint</a> module are intended to print out Python data in a nice way. If your goal is however to be able to deserialize the data later, you can have a look at the <a href="https://en.wikipedia.org/wiki/JSON" rel="nofollow">JSON</a> format and its <a href="http://docs.python.org/3.3/library/json.html?highlight=json#module-json" rel="nofollow">Python module</a></p> <pre class="lang-py prettyprint-override"><code>&gt;&gt;&gt; import pprint &gt;&gt;&gt; pp = pprint.PrettyPrinter(indent=4) &gt;&gt;&gt; pp.pprint(myIndex) { '411)': {2173: 1}, 'augmented': {1350: 1}, 'format-free': {720: 1}, 'function,': {485: 1, 831: 1, 1579: 1}, 'incorporating': {2047: 1}, 'understand': {2396: 1}} &gt;&gt;&gt; import json &gt;&gt;&gt; output = json.dumps(myIndex,sort_keys=True,indent=4, separators=(',', ': ')) &gt;&gt;&gt; print(output) { "411)": { "2173": 1 }, "augmented": { "1350": 1 }, "format-free": { "720": 1 }, "function,": { "485": 1, "831": 1, "1579": 1 }, "incorporating": { "2047": 1 }, "understand": { "2396": 1 } } &gt;&gt;&gt; myRecoveredIndex = json.loads(output) &gt;&gt;&gt; list(myRecoveredIndex.keys()) ['format-free', 'incorporating', 'function,', 'understand', 'augmented', '411)'] &gt;&gt;&gt; </code></pre> <p>If the format you suggested does matter, you can then write the file yourself according to your format. Here is a suggestion of how to do it:</p> <pre class="lang-py prettyprint-override"><code>with open("myfile.txt", "w") as fstream: for key, data in myIndex.items(): fstream.write("'{}': {!s}\n".format(key, data)) </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload