ファイルパスは相対パスで組み立てる(file

投稿者: | 2022-11-08
  • どこからでもプログラムが実行されても動くようにパスを組み立てる
  • 実行されるプログラムを起点としたパスをつくる
import ccv
from pathlib import Path

# 起点となるプログラムがあるパスの作り方
here = Path(__file__).parent
CSV_PATH = here / 'target.csv'

with open(CSV_PATH, mode='r') as f:
  reader = csv.reader(f)
  for row in reader:
    print(row)