Created
March 6, 2019 02:26
-
-
Save ZhigangPu/29e4f511185dacf30a910d7285a94ec1 to your computer and use it in GitHub Desktop.
string compatibility of python3 and python2
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
PY2 = sys.version_info[0] == 2 | |
if PY2: | |
text_type = unicode | |
string_types = (unicode, str) | |
from cStringIO import StringIO as NativeBytesIO | |
else: | |
text_type = str | |
string_types = (str,) | |
from io import BytesIO as NativeBytesIO |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment