0
2

More than 3 years have passed since last update.

with openのファイル操作—「../」

Last updated at Posted at 2019-12-24

with openのファイル構造、操作がよくわからなかった

sample.pyの場所
 Python → robot → hello → sample.py

hello.txtの場所
 Python → robot → templates → hello.txt

sample.py
#クラスの一部コードを記載
 def hello(self):
        with open("../templates/hello.txt", encoding="utf-8") as f:
            t = string.Template(f.read())
            contents = t.substitute(robot_name = self.name)
            print(contents)
            user_name = input()

「../」を上手く使えばできる

0
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
2