2018-08-23から1日間の記事一覧
os を使う import os currnet_dir = os.path.dirname( os.path.abspath(__file__) ) os.path.abspath(__file__) で現在のファイルの絶対パスを取得し、os.path.dirname(path)でファイルのあるディレクトリを取得。 参照: 10.1. os.path — 共通のパス名操作 —…
classキーワードに続けて大文字から始まるクラス名を記述してクラスを作成する クラスからインスタンスを作成する際はnewなどのキーワードは不要 コンストラクタは__init__()で定義する class Player: # constructor def __init__(self, name = 'Human'): se…