当前位置:网站首页>二进制、八进制、十六进制
二进制、八进制、十六进制
2022-07-06 21:02:00 【远吗我的香格里拉】
数字转为字符串:bin()、oct()、hex()
>>> bin(15) #二进制
'0b1111'
>>> oct(15) #八进制
'0o17'
>>> hex(15) #十六进制
'0xf'
字符串转为数字:int()
>>> int('0b1111',2) #二进制
15
>>> int('0o17',8) #八进制
15
>>> int('0xf',16) #十六进制
15
格式化显示
>>> "{0:#x}".format(0xf) #小写字母,十六进制数字
'0xf'
>>> "{0:#X}".format(0xf) #大写字母
'0XF'
>>> "{0:#x}".format(15) #小写字母,十进制数字
'0xf'
>>> "{0:x}".format(15) #小写字母,十进制数字,不带前缀0x
'f'
>>> "{0:0>8x}".format(255) #占8位字符,左对齐,补0
'000000ff'
边栏推荐
- Optimization cases of complex factor calculation: deep imbalance, buying and selling pressure index, volatility calculation
- Appx code signing Guide
- Vernacular high concurrency (2)
- 未来发展路线确认!数字经济、数字化转型、数据...这次会议很重要
- Basic concepts of Huffman tree
- Restcloud ETL Community Edition June featured Q & A
- Tencent cloud native database tdsql-c was selected into the cloud native product catalog of the Academy of communications and communications
- Not All Points Are Equal Learning Highly Efficient Point-based Detectors for 3D LiDAR Point
- Search of linear table
- 1200.Minimum Absolute Difference
猜你喜欢

About Confidence Intervals

再AD 的 界面顶部(菜单栏)创建常用的快捷图标

Que savez - vous de la sérialisation et de l'anti - séquence?

什么是 BA ?BA怎么样?BA和BI是什么关系?

About Confidence Intervals

Create applet from 0

QT opens a file and uses QFileDialog to obtain the file name, content, etc

SQL injection -day15
![[security attack and Defense] how much do you know about serialization and deserialization?](/img/1c/e5ae74e65bacf688d7f61cc1b71d3e.png)
[security attack and Defense] how much do you know about serialization and deserialization?

Kotlin Android 环境搭建
随机推荐
Baidu map JS development, open a blank, bmapgl is not defined, err_ FILE_ NOT_ FOUND
[leetcode] 700 and 701 (search and insert of binary search tree)
SSL证书部署
Depth analysis of compilation constants, classloader classes, and system class loaders
Gpt-3 is a peer review online when it has been submitted for its own research
本机mysql
Huawei and Xiaomi "copy each other"
21.(arcgis api for js篇)arcgis api for js矩形采集(SketchViewModel)
代码质量管理
SSL certificate deployment
RestClould ETL 社区版六月精选问答
R数据分析:cox模型如何做预测,高分文章复现
25. (ArcGIS API for JS) ArcGIS API for JS line modification line editing (sketchviewmodel)
First understand the principle of network
函数重入、函数重载、函数重写自己理解
预处理——插值
PHP lightweight Movie Video Search Player source code
Graphical tools package yolov5 and generate executable files exe
Probability formula
链表面试常见题