lexus

PYTHON实现 字符串转化为十六进制串 - 阿毛小猪 - 博客园

4| Ping  -> \34\7c\50\69\6e\67

处理以前的文档,有几十条数据都是给出了值而没有给出code,因此写了个小小的转换。用UltraEdit打开文件,这样调用一次,生成的两行数据复制起来很方便

def a(input):
    f = open(\'a.txt\',\'a\')  
    payload = ""
    code = ""
    for i in input:
        payload += \' \'+hex(ord(i))[2:]
        code += \'\\\'+hex(ord(i))[2:]
    print payload
    print code
    print len(input)
    f.write(code +\'\n\')
    f.write(payload+\'\n\')

 相信PYTHON还有更多更牛的实现办法的^

分类:

技术点:

相关文章: