とりいそぎ
重み付きランダム選択
weight_random.py
import random
data = ["1","2","3"]
w = [5,3,2]
for i in range(10):
print(random.choices(data,weight=w))
# result(期待値)
# "1":5回
# "2":3回
# "3":2回
自身が置いてあるディレクトリ名の取得
self_dir_name.py
import os,sys
print(os.path.dirname(sys.argv[0]))
# result
# C:\~~~
半角大文字英語と数字のリスト
alph_num.py
alph = [chr(i) for i in range(65, 65+26)]
num = [chr(i) for i in range(48,48+10)]
# result
# alph = ["A",...,"Z"]
# num = ["0",...,"9"]