Pythonでファイルの処理

カレントディレクトリ取得

import os
print(os.environ['HOME'])

もしファイルが無かったら作成する

if os.path.isfile(path) is False:
    f = open(path, 'w')
    f.write('0\n')
    f.close()

ファイルの文字列呼び出し

f = open(path, 'r')
for row in f:
    id = row.strip()