質問編集履歴
4
タイトルをシンプルに変更
title
CHANGED
@@ -1,1 +1,1 @@
|
|
1
|
-
(Python) 別のディレクトリにあるファイルをopenできない
|
1
|
+
(Python) 別のディレクトリにあるファイルをopenできない ※モジュールとして実行する場合
|
body
CHANGED
File without changes
|
3
リンクの変更
title
CHANGED
File without changes
|
body
CHANGED
@@ -7,7 +7,7 @@
|
|
7
7
|
|
8
8
|
#ファイルをうまく取得できるケース
|
9
9
|
下記のようなディレクトリ構造においてファイルを実行したとき,ファイルをうまく取得できました。
|
10
|
-
※ちなみにこれは,前回の質問「[(Python) 別のディレクトリにあるファイルを
|
10
|
+
※ちなみにこれは,前回の質問「[(Python) 別のディレクトリにあるファイルをopenできない](https://teratail.com/questions/360842)」が解決した成果です。
|
11
11
|
|
12
12
|
|
13
13
|
```
|
2
コードに一部コメントを追加 sys.path.append('..')
title
CHANGED
File without changes
|
body
CHANGED
@@ -57,7 +57,7 @@
|
|
57
57
|
# $bigquery_app/base.py 実行ファイルパス
|
58
58
|
|
59
59
|
os.chdir(os.path.dirname(os.path.abspath(__file__)))
|
60
|
-
sys.path.append('..')
|
60
|
+
sys.path.append('..') #これはimportのパスの起点には影響するがファイル取得(カレントディレクトリ)には影響しない※前回の質問でご教示いただいた内容
|
61
61
|
from configurator import Configurator
|
62
62
|
class BigqueryBase:
|
63
63
|
def __init__(self, ...):
|
1
sys.path.append('..')
title
CHANGED
File without changes
|
body
CHANGED
@@ -57,6 +57,7 @@
|
|
57
57
|
# $bigquery_app/base.py 実行ファイルパス
|
58
58
|
|
59
59
|
os.chdir(os.path.dirname(os.path.abspath(__file__)))
|
60
|
+
sys.path.append('..')
|
60
61
|
from configurator import Configurator
|
61
62
|
class BigqueryBase:
|
62
63
|
def __init__(self, ...):
|