taca

time

time.time_ns()

使い方 int = time.time_ns() UNIXエポックを基準とした経過ナノ秒が表示されますUNIXエポックは1970.1.1 0:0:0です import time int1 = time.time_ns()...
組み込み関数

len() サイズ

使い方 int = len( obj ) objのサイズを返します txt='abc' print(len(txt)) #結果 3 文字列str の文字数を返します list1=] print...
組み込み関数

id()

使い方 int = id(obj) objのオブジェクトIDを整数でかえします a = id(1) print(a) #結果 140715887236880
組み込み関数

ord()

使い方 int = ord( str ) 文字を与えるとUnicodeが戻ります複数の文字を与えるとエラーになります int1 = ord('a') print(int1) #結果 97 chr()...
re

re.compile() パターン

使い方 obj = re.compile(パターン) 「パターン」をobjに格納します import re pattern=re.compile('a') print(pattern) #結果 re.co...
組み込み関数

str()

使い方 str = str( obj ) 渡したobjのstr型を返します int1 = 1 str1 = str(int1) print(type(str1),str1) #結果 <class 'str&...
Uncategorized

ドラッグ&ドロップ① windnd

windndを使用してドラッグ&ドロップされたファイルのリンクを取得 tkinterにドラッグ&ドロップします。 非常にシンプルですが2バイト文字が変換されてしまいます # pip install windnd impo...
組み込み関数

set()

使い方 set = set( iterable ) イテラブルを渡すとsetを返します list1 = iter1 = set(list1) print(iter1) #結果 {1, 2, 3}
組み込み関数

issubclass()

使い方 bool = issubclass( type1 , type2 ) type1がtype2のサブクラスの場合Trueが返ります bool1 = issubclass(bool,int) print(bool1)...
組み込み関数

divmod()

使い方 tuple = divmod(a,b) aをbで割った商とあまりをタプルで返します tuple = divmod(7,2) print(tuple) #結果 (3,1) 7 ÷ 2= 3…1 a,bと...