Japanese prettyprint memo (also python2.7 & 3.5 windows7)

The dictionary type outputs properly even in Japanese. I'm very grateful. It also supports dictionary types with complicated structures.

For example, use it as follows.

dic={} #Make the contents appropriately
pp(dic) #Just output
a=pp_str(dic) #When receiving the result in a variable

Get it from github below. With windows, easy_install didn't work. (There was no error ... Did you forget something?)

Two files in the prettyprint folder https://github.com/taichino/prettyprint/tree/master/prettyprint It works if you arrange it properly.

I confirmed the operation on ubuntu. I think it's easier than printing (pp ()). There are various pps and I'm not sure about it ...

** When using with python3 ** Convert the print statement to parentheses and It worked if the return value of the pp_str () function below eval was simply set to orig.

However, when the u code was included, the characters were garbled this time> <

Postscript:

return orig.encode('utf-8').decode('unicode_escape') And the Japanese display has passed! Reference: In this example, the encoding / decoding is reversed. http://kwatch.houkagoteatime.net/blog/2013/12/07/python-tips/

By examination, python3 already had a pprint module. Import it into the original pretyprint.py and change the original pp function to pp_ etc. W that works for the time being with the following description

However, the type of the return value of this one is a unique class I don't know if the contents can be taken out without checking

import pprint

def pp(obj):
  pprint.pprint(obj)

reference I want to pretty print a list and dictionary including Japanese in Python http://taichino.com/programming/1599

taichino/prettyprint https://github.com/taichino/prettyprint

Recommended Posts

Japanese prettyprint memo (also python2.7 & 3.5 windows7)
[Python] Memo to translate Matplotlib into Japanese [Windows]
Python environment construction memo on Windows 10
Python memo
python memo
python memo
Python memo
Python memo
Python memo
[Python] Memo dictionary
python beginner memo (9.2-10)
Python on Windows
python windows environment
★ Memo ★ Python Iroha
[Python] EDA memo
Python 3 operator memo
[My memo] python
[Python] Basemap memo
Python beginner memo (2)
[Python] Numpy memo
Python I'm also basic
My python environment memo
Python module (Python learning memo ④)
Visualization memo by Python
python windows environment construction
Python installation method Windows
Python test package memo
[Heroku] Memo for deploying Python apps using Heroku on Windows [Python]
[Python] Memo about functions
python regular expression memo
Binary search (python2.7) memo
[My memo] python -v / python -V
Python starting with Windows 7
Python3 List / dictionary memo
[Memo] Python3 list sort
Python Tips (my memo)
[Python] Memo about errors
Python error list (Japanese)
DynamoDB Script Memo (Python)
python basic on windows ②
Install python on windows
Python basic memo --Part 2
python recipe book Memo
Basic Python command memo
Python OpenCV tutorial memo
Japanese output in Python
Python basic grammar memo
TensorFlow API memo (Python)
python Environmentally-friendly Japanese setting
python useful memo links
Python decorator operation memo
Python basic memo --Part 1
Install Python (for Windows)
OpenJTalk on Windows10 (Speak Japanese with Python from environment construction)
Python environment construction procedure memo using Docker on Windows10 Home
Set-enable Python virtualenv on Windows
Python with VS Code (Windows 10)
Send Japanese email with Python3
Python memo (for myself): Array
Python exception handling (Python learning memo ⑥)
How to install Python [Windows]