taca

Uncategorized

ドラッグ&ドロップ① windnd

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

oct() 8進数に変換

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

bin()

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

time.sleep()

使い方 time.sleep(int1) int1 秒間停止します import time time.sleep(3) #結果 3秒間停止します
組み込み関数

type()

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

time.thread_time()

使い方 float = time.thread_time() CPU時間を秒で返します import time float1 = time.thread_time() print(flaot1) #結果 1.01562...
re

re.finditer() 抽出

使い方 iter = re.finditer(抽出文字,対象) 「対象」の中から「抽出文字」の条件に合う文字列をイテレータにします。 import re txt='sky blue star' iter=...
組み込み関数

map()

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

re.compile() パターン

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

re.fullmatch() 抽出

使い方 obj = re.fullmatch(抽出文字,対象) 「対象」と抽出文字が完全に一致した時に抽出します import re txt='abcdefg' obj=re.fullmatch(&#39...