Quantcast
Channel: Active questions tagged utf-8 - Stack Overflow
Viewing all articles
Browse latest Browse all 1223

simplest way to read standard JSON with UTF8 Latin Letters

$
0
0

My server only offers Python v2.7.5.

This script is working:

import jsonwith open('Ranger_Policies.json', 'r') as f:    data = json.loads(f.read())for p in data['policies']:    print "Service:", p['service'] #, "Name:", p['name']

When I remove the comment-mark, the p['name'] triggs an error:

UnicodeEncodeError: 'ascii' codec can't encode character u'\u2019' in position 29: ordinal not in range(128)

How to correct this specific source code, it must work with any standard UTF8 for Latin.


Viewing all articles
Browse latest Browse all 1223

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>