0
我正在使用Azure Batch和Python,我想從批處理任務中的共享空間內創建一個目錄。
按照docs:
共享:此目錄提供讀取到的節點上運行的所有任務/寫訪問。節點上運行的任何任務都可以創建,讀取,更新和刪除此目錄中的文件。任務可以通過引用AZ_BATCH_NODE_SHARED_DIR環境變量來訪問此目錄。
想象,文件夾名爲test_dir
:
if not os.path.exists('test_dir'):
os.makedirs('test_dir')
現在,如果我想要寫一個文件到該目錄是什麼?我不能使用:
with open('$AZ_BATCH_NODE_SHARED_DIR/test_dir/test.txt', 'a') as output:
output.write('hello\n')
如何從$AZ_BATCH_NODE_SHARED_DIR
獲得完整路徑?