組み込み関数

組み込み関数

sorted()

使い方 list = sorted( iterable ) iterableを渡すとソートしたlistを返します list1 = list2 = sorted( list1 ) print( list2 ) #結果 ...
組み込み関数

hash()

使い方 int =hash(tuple) tupleをハッシュ化して返します tuple1='dopy',777 hash(tuple1) #結果 604267554648750771
組み込み関数

bin()

使い方 str = bin(int) 整数を2進数に変換します先頭には2進数を示す0bが付きます str = bin(7) print(str) #結果 0b111
組み込み関数

type()

使い方 type1 = type( obj ) 渡したobjのtypeを返します str1 = 'abc' type1 = type( str1 ) print(type1) #結果 <class ...
組み込み関数

zip()

使い方 zip = zip( *iterable ) 複数のiterableを渡すと要素をまとめて返します list1 = tuple1 = ('A','B','C') ...
組み込み関数

isinstance()

使い方 bool = isinstance( obj , type) objの型がtypeと一致した場合Trueが返ります bool1 = isinstance(111,int) print(bool1) #結果 Tru...
組み込み関数

oct() 8進数に変換

使い方 str = oct( int ) octに与えた値の8進数が文字列で返ります先頭には0o(ゼロ オー)が付与されます str1 = oct(64) print(str1) #結果 0o100 10進数への戻...
組み込み関数

format()

使い方 str1 = str2.format(value) valueの値をstr2のフィールドに入れた文字列をstr1に返します str1 = '作成日は{}月{}日{}曜日です' str2 = str...
組み込み関数

min() 最小値

使い方 int = min(iterable) minに渡した最小値が返ります list1= print(min(list1)) #結果 1
組み込み関数

map()

使い方 map = map( function , iterable) iterableのすべての要素にfunctionを適応した結果をiterableで返します lambdaを利用 list1= map1=(ma...