标签: python python-3.x
如果给定的字符串仅包含 utf-8 个字符,如何检入python3?
答案 0 :(得分:2)
如果您在谈论bytes,则可以执行以下操作:
bytes
data = bytearray([0xF0]) try: data.decode("UTF-8", "strict") except UnicodeDecodeError: print("Not UTF-8") else: print("UTF-8")