def str_to_hex(s): return r"/x"+r'/x'.join([hex(ord(c)).replace('0x', '') for c in s]) def hex_to_str(s): ) :]]]) def str_to_bin(s): return ' '.join([bin(ord(c)).replace('0b', '') for c in s]) def bin_to_str(s): ) for b in s.split(' ')]]) a=&quo
vim 先用vim -b data 以2进制打开文件,然后用xxd工具转化,在vim的命令行模式下: :%!xxd --将当前文本转化为16进制格式 :%!xxd -r --将16进制转化为普通文本 hexdump hexdump可以用来查看二进制文件的16进制结果 hexdump data 如果文件比较大可以用 hexdump data | less 分页显示 如果想得到16进制和ascii码对应的显示结果,可以添加 -C参数 hexdump -C data | less
Very often, especially in programming contests, we treat a sequence of non-whitespace characters as a string. But sometimes, a string may contain whitespace characters or even be empty. We can have such strings quoted and escaped to handle these case