# 字符转成字节
bytes1 = bytes('你好啊', encoding='utf-8')
print(bytes1) # b'\xe4\xbd\xa0\xe5\xa5\xbd\xe5\x95\x8a'
# 字节转成字符
string1 = str(bytes1, encoding='utf-8')
print(string1) # 你好啊
# 字符转成字节数组
byteArray1 = bytearray('你好啊', encoding='utf-8')
print(byteArray1) # bytearray(b'\xe4\xbd\xa0\xe5\xa5\xbd\xe5\x95\x8a')
# 字节数组转成字符
string2 = str(byteArray1, encoding='utf-8')
print(string2) # 你好啊
# bool类型转换
# return False
print(bool({}))
print(bool(()))
print(bool(("")))
print(bool([]))
print(bool(""))
print(bool(None))
# return True
print(bool(" "))
print(bool({"":""}))
print(bool([""]))
# ASCII
print(chr(32)) # 空格
print(chr(48)) # 0
print(chr(57)) # 9
print(chr(65)) # A
print(chr(90)) # Z
print(chr(97)) # a
print(chr(122)) # z
print(ord(' ')) # 32
print(ord('A')) # 65