[Py] Python 字符串 str 和 字节 bytes 的互转

通过llama.cpp与羊驼聊天的网页界面- 详解 Serge 的启动使用

 

字节转字符串:

st = str(data, encoding = "utf8")

print(st)

print(type(str)) # <class 'str'>

 

字符串转字节:

by = bytes(st, encoding = "utf8")

print(by)

print(type(by)) # <class 'bytes'> 

 

Refer:在线运行Python代码

Link:https://www.cnblogs.com/farwish/p/13219028.html

posted on 2020-07-01 14:21  ercom  阅读(1180)  评论(0编辑  收藏  举报