文章详情页
javascript - js代码转python
浏览:286日期:2022-06-28 09:37:27
问题描述
js代码如下
var e = a.charCodeAt(t).toString(16);这一行不明白
function encode_unicode_param(a) { for (var s = '', t = 0; t < a.length; t++) {var e = a.charCodeAt(t).toString(16);s += 2 == e.length ? 'n' + e: e } return s}
问题解答
回答1:python3 下:
def encode_unicode_param(s): results = [] for char in s:h = hex(ord(char))[2:]format_string = ’n{}’ if len(h) == 2 else ’{}’results.append(format_string.format(h)) return ’’.join(results)
相关文章:
排行榜

网公网安备