网创优客建站品牌官网
为成都网站建设公司企业提供高品质网站建设
热线:028-86922220
成都专业网站建设公司

定制建站费用3500元

符合中小企业对网站设计、功能常规化式的企业展示型网站建设

成都品牌网站建设

品牌网站建设费用6000元

本套餐主要针对企业品牌型网站、中高端设计、前端互动体验...

成都商城网站建设

商城网站建设费用8000元

商城网站建设因基本功能的需求不同费用上面也有很大的差别...

成都微信网站建设

手机微信网站建站3000元

手机微信网站开发、微信官网、微信商城网站...

建站知识

当前位置:首页 > 建站知识

Python中oct()函数的语法-创新互联

这篇文章主要介绍Python中oct()函数的语法,文中介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们一定要看完!

成都创新互联公司主要从事成都网站设计、成都网站建设、网页设计、企业做网站、公司建网站等业务。立足成都服务扬州,10多年网站建设经验,价格优惠、服务专业,欢迎来电咨询建站服务:18982081108

什么是oct函数?

oct()函数是Python3中的内置方法之一。 oct()方法采用整数,并以字符串格式返回其八进制表示形式。

oct()语法如下:

Syntax : oct(x) #语法
 
Parameters :   #参数
 
x – Must be an integer number and can be in either binary, decimal or hexadecimal format.
#  x必须为整数,并且可以为二进制,十进制或十六进制格式。
 
Returns : octal representation of the value.#返回值的八进制表示形式。
 
Errors and Exceptions :   #错误和异常:
TypeError : Returns TypeError when anything other than integer type constants are passed as parameters.
#TypeError:当将整数类型常量以外的任何内容作为参数传递时,返回TypeError。

oct()函数的用法

print("The octal representation of 23 is " + oct(23))
print("The octal representation of the"
" ascii value of 'z' is " + oct(ord('z')))
print("The octal representation of the binary"
" of 23 is " + oct(0b10111))
print("The octal representation of the binary"
" of 23 is " + oct(0x17))

输出:

The octal representation of 23 is 0o27
The octal representation of the ascii value of 'z' is 0o172
The octal representation of the binary of 23 is 0o27
The octal representation of the binary of 23 is 0o27

以上是Python中oct()函数的语法的所有内容,感谢各位的阅读!希望分享的内容对大家有帮助,更多相关知识,欢迎关注创新互联行业资讯频道!


分享文章:Python中oct()函数的语法-创新互联
文章网址:http://bjjierui.cn/article/pcdig.html

其他资讯