<jupyter_start><jupyter_text>bytes/str- bytes: 包含原始的8位值：即8位bit表示一个char- str: 包含unicode字符- 两者之间的转换：utf-8:编码方式<jupyter_code>def to_str(bytes_or_str):
    if isinstance(bytes_or_str,bytes):
        return bytes_or_str.decode("utf-8")
    return bytes_or_str

def to_bytes(bytes_or_str):
    if isinstance(bytes_or_str,str):
        return bytes_or_str.encode("utf-8")
    return bytes_or_str<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.11004784688995216, 'fraction_numerical': 0.011961722488038277, 'mean_word_length': 5.650793650793651, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '122915', 'license': 'Apache-2.0', 'n_tokens_mistral': 184, 'n_tokens_neox': 192, 'n_words': 21, 'path': 'bytes,str,unicode.ipynb', 'repo_name': 'weridolin/effective-python-learn', 'size': '418'}