#!/usr/bin/env python # -*- coding: utf-8 -*- # @Date : 2016-08-12 12:12:06 # @Author : PiaoYun (piaoyunsoft@163.com) # @Link : http://www.dllhook.com # @comment : 进制转换测试 def log(s1, s2): return ("%s: %s" % (s1, s2)) print(log('16->10', int('0xA', 16))) print(log('2->10', int('0101', 2))) print(log('8->10', int('17', 8))) print("\n") print(log('10->16', hex(10))) print(log('2->16', hex(int('0101', 2)))) print(log('10->16', hex(10))) print(log('8->16', hex(int('17', 8)))) print("\n") print(log('10->2', bin(5))) print(log('16->2', bin(int('0xA', 16)))) print(log('8->2', bin(int('17', 8)))) print("\n") print(log('2->8', oct(0b0101))) print(log('10->8', oct(11))) print(log('16->8', oct(0xF)))
发表评论