Skip to content

Instantly share code, notes, and snippets.

@ZhigangPu
Created March 6, 2019 02:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ZhigangPu/29e4f511185dacf30a910d7285a94ec1 to your computer and use it in GitHub Desktop.
Save ZhigangPu/29e4f511185dacf30a910d7285a94ec1 to your computer and use it in GitHub Desktop.
string compatibility of python3 and python2
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