python3.5 for循环每次取出一个字符(不是字节)
#!/usr/bin/env python # -*- coding:utf-8 -*- my_str = "我是哈哈" for i in my_str: my_bytes = bytes(i, ‘utf-8‘) print(my_bytes) my_bytes = bytes(i, ‘gbk‘) print(my_bytes) for i in my_str: my_bytes = bytes(i, ‘utf-8‘) for b in my_bytes: print(hex(b)) print(bin(b)) print(oct(b)) print(b)
时间: 2024-10-12 11:32:27