"""UTF-8 编解码,用于 property-based 测试。""" from __future__ import annotations def encode(text: str) -> bytes: return text.encode("utf-8") def decode(data: bytes) -> str: return data.decode("utf-8") def main() -> None: text = "你好, Python" print(f"encoded: {encode(text)!r}") print(f"roundtrip: {decode(encode(text)) == text}") if __name__ == "__main__": main()