Python 字串數字之間轉換

2021-10-23 02:32:54 字數 459 閱讀 4103

int(x [,base ]) 將x轉換為乙個整數

long(x [,base ]) 將x轉換為乙個長整數

float(x ) 將x轉換到乙個浮點數

complex(real [,imag ]) 建立乙個複數

str(x ) 將物件 x 轉換為字串

repr(x ) 將物件 x 轉換為表示式字串

eval(str ) 用來計算在字串中的有效python表示式,並返回乙個物件

tuple(s ) 將序列 s 轉換為乙個元組

list(s ) 將序列 s 轉換為乙個列表

chr(x ) 將乙個整數轉換為乙個字元

unichr(x ) 將乙個整數轉換為unicode字元

ord(x ) 將乙個字元轉換為它的整數值

hex(x ) 將乙個整數轉換為乙個十六進製制字串

oct(x ) 將乙個整數轉換為乙個八進位制字串

python字串與數字之間的轉換

usr bin python death age 80name input your name age input your age input 接受的所有資料都是字串,即便你輸入的是數字,但依然會被當成字串來處理 print type age int inteager 整數 把字串轉成int,用i...

字串,數字之間的轉換

數字 字串 cstring ntos double d else if sign 1 str.insert 0,return str 字串 數字 double ston cstring str 10進製 2進製 void ccalculation dec2bin cstring strexp int...

數字與字串之間的轉換

c語言為我們提供了數字和字串之間的轉換函式,這些函式有很多,常用的有 整型數轉字串函式itoa char itoa int value,char string,int radix int value 被轉換的整數,char string 轉換後儲存的字元陣列,int radix 轉換進製數,如2,8...