要求: 统计字符串中,各个字符的个数 比如:“hello world” 字符串统计的结果为:{‘h’: 1, ‘e’: 1, ‘l’: 3, ‘o’: 2, ‘w’: 1, ‘r’: 1, ‘d’: 1} 代码实现: str01 = "hello world" # 定义一个字典,用来存储结果 result_dict = { } for i in str01: if i == " ": continue result_dict[i