文章详情页
javascript - js代码转python
浏览:129日期: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)
相关文章:
1. mysql - JAVA怎么实现一个DAO同时实现查询两个实体类的结果集2. sql语句 - 如何在mysql中批量添加用户?3. mysql建表报错,查手册看不懂,求解?4. PHP类属性声明?5. 求大神支招,php怎么操作在一个html文件的<head>标记内添加内容?6. 怎么php怎么通过数组显示sql查询结果呢,查询结果有多条,如图。7. 致命错误: Class ’appfacadeTest’ not found8. 老师们php,插入数据库mysql,都是空的,要怎么解决9. mysql - 数据库建字段,默认值空和empty string有什么区别 11010. phpstady在win10上运行
排行榜
