约 463 字
约 2 分钟
说明:类型转换为 bytearray。
def bytearray(x):
'''
类型转换为 bytearray
:param x: 一个变量
:return: x 转换为 bytearray 后的值
'''
示例:
print(bytearray(10)) # 长度为 10 的,值全 0
print(bytearray(b'hello')) # from bytes
print(bytearray('hello', encoding='utf-8')) # from str
创建于 2025/5/9
更新于 2025/5/16