Python 十进制转二进制、八进制、十六进制
Python 3 教程
· 2019-02-12 12:59:28
以下代码用于实现十进制转二进制、八进制、十六进制:
实例(Python 3.0+)
# -*- coding: UTF-8 -*-
# Filename : test.py
# author by : www.codercto.com
# 获取用户输入十进制数
dec = int(input("输入数字:"))
print("十进制数为:", dec)
print("转换为二进制为:", bin(dec))
print("转换为八进制为:", oct(dec))
print("转换为十六进制为:", hex(dec))
执行以上代码输出结果为:
python3 test.py 输入数字:5 十进制数为:5 转换为二进制为: 0b101 转换为八进制为: 0o5 转换为十六进制为: 0x5
python3 test.py 输入数字:12 十进制数为:12 转换为二进制为: 0b1100 转换为八进制为: 0o14 转换为十六进制为: 0xc
点击查看所有 Python 3 教程 文章: https://codercto.com/courses/l/10.html
Invisible Users
Jenna Burrell / The MIT Press / 2012-5-4 / USD 36.00
The urban youth frequenting the Internet cafes of Accra, Ghana, who are decidedly not members of their country's elite, use the Internet largely as a way to orchestrate encounters across distance and ......一起来看看 《Invisible Users》 这本书的介绍吧!
图片转BASE64编码
在线图片转Base64编码工具
XML、JSON 在线转换
在线XML、JSON转换工具