フォルダー A に db ファイルのディレクトリがあります。私の python コードは別の場所から実行されます。
次のコードを実行すると:
path = 'xxx' # path to file directory
filenames = os.listdir(path) # list the directory file names
#pprint.pprint(filenames) # print names
newest=max(filenames)
print newest # print most recent file name
# would like to open this file and write to it
data=shelve.open(newest, flag="w")
最後の行まで機能すると、次のようなエラーが表示されますneed "n" or "c" flag to run new db
。
最後の行にフラグがない場合、例: data=shelve.open(newest)
、ファイル名は db にデータなしで Python コードのディレクトリに到着します。
newest によって返されたファイル名を " " に入れる必要がありますが、方法がわかりません。