日韩无码专区无码一级三级片|91人人爱网站中日韩无码电影|厨房大战丰满熟妇|AV高清无码在线免费观看|另类AV日韩少妇熟女|中文日本大黄一级黄色片|色情在线视频免费|亚洲成人特黄a片|黄片wwwav色图欧美|欧亚乱色一区二区三区

RELATEED CONSULTING
相關咨詢
選擇下列產品馬上在線溝通
服務時間:8:30-17:00
你可能遇到了下面的問題
關閉右側工具欄

新聞中心

這里有您想知道的互聯(lián)網營銷解決方案
創(chuàng)新互聯(lián)Python教程:Python中的oct() 函數是什么?

有小伙伴們對oct函數有了解的嗎?可能有小伙伴們反映說從來沒有見過的吧,更不知道是怎么要用,我們都知道語言是一個非常連貫的整體,任何一個環(huán)節(jié),我們不知道內容,都可能造成下面的內容不會銜接,所以對于生僻的內容,我們一定要學會掌握,或者了解下,知道意思即可,好啦,不多說了,一起來看下吧~

什么是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

沒想到吧,就這簡簡單單三個字母的函數,居然有這么強大的功能,多多掌握一些函數還是非常有益處的,關于這個函數還有無窮的使用技巧,大家先掌握部分,下部分內容跟隨項目來學習吧~


當前標題:創(chuàng)新互聯(lián)Python教程:Python中的oct() 函數是什么?
地址分享:http://www.5511xx.com/article/coedche.html