Passing a JSON document in Python -
I am trying to pass a policy document to be encoded in base64.
The policy document is located on What do I need to do to pass it in Base 64 to get the ~ / policy_document
on & gt; & Gt; & Gt; Policy = base64.b64encode (policy_document)
policy_document ? Thank you.
# Open the first file # Then read all contents in memory & gt; & Gt; & Gt; Policy_document = open ("/ absolute / path / to / policy_document", "r"). Read () # Then Base 64 Encoded Content. & Gt; & Gt; & Gt; Policy = base64.b64encode (policy_document) # If you are using Python 2.7, you can clear the files to # with # statement to make sure # (see @ Nickels' comment); & Gt; & Gt; Fp: ... policy_document = fp.read () ... with open ("/ absolute / path / to / policy_document", "r") ... policy = base64.b64encode (policy_document) # fp Alternatively, if you need it current to the user's home folder, you
Comments
Post a Comment