简体   繁体   中英

How do I check for UTF-8 encoded data (bytes) in python 2.4

In higher versions of python i can do:

isinstance(s_out, bytes)

There is no 'bytes' in python2.4. Is there an equivalent of doing this in python2.4 which also works for all other python versions?

import sys

if sys.version_info < (2, 7):
    bytes = str


if isinstance(s_out, bytes):

I really don't know the context but wouldn't it better to upgrade at least to python 2.7 and not lose time trying to make code python 2.4 compatible.

I do not know the target systems and the OS, but could imagine that it is possible to install a more recent python and invest the time to make the code work with newer pythons.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM