2021-12-31 myluzh
RouterOS
用的就是url gb2313编码
import urllib
from urllib import parse
def url_gb2312(t_type, text):
if t_type == "encode":
text = urllib.parse.quote(text.encode('gb2312'))
text = text.replace("%", "\\")
return text
if t_type == "decode":
text = text.replace("\\", "%")
text = urllib.parse.unquote(text, encoding='gb2312')
return text
# 编码
t = url_gb2312("encode", "哈哈哈")
print(t) # 输出 \B9\FE\B9\FE\B9\FE
# 解码
t = url_gb2312("decode", "\B9\FE\B9\FE\B9\FE")
pr...
阅读全文>>
标签: python routeros 中文
评论(0)
(1290)