读取文件2.py 237 B

123456
  1. from pathlib import Path # pathlib is recommended
  2. #repofile = Path('../repo_file.txt') # 读取上一级目录文件
  3. repofile = Path('./repo_file.txt') # 读取上一级目录文件
  4. with repofile.open() as f:
  5. print(f.readline())