1
ジップそれらを1つのファイルに変換します。私は<code>Dest_Dir</code>でランダムな名前(私の先のディレクトリ)にファイルを大量に作成する必要があり、そしてジップ、私はPythonで初心者だ</p> <p>をPythonでランダムな名前を持つファイルの乗算量を作成し、それらを
これを行う方法を知っている人はいますか? for
のようなファイルを特定のフォルダにループして作成することができましたが、大量のファイルを作成したい場合に適していません。 作成した名前はランダムではありません。
import os
import sys
import platform
SRC_Dir = os.path.dirname(__file__)
Dest_Dir = os.path.join(SRC_Dir, 'dest')
items = ["one", "two", "three"]
for item in items:
#(os.path.join(Dest_Dir, filename), 'wb') as temp_file:
with open(os.path.join(Dest_Dir, item), 'wb') as f:
f.write("This is my first line of code")
f.write("\nThis is my second line of code with {} the first item in my list".format(item))
f.write("\nAnd this is my last line of code")
コードの試しに[mcve]を入力してください。 – idjaw
まず、['random'](https://docs.python.org/2/library/random.html)と[' zipfile'](https://docs.python.org/2/library)を読んでください。/zipfile.html)モジュール。 – Selcuk
彼はおそらくフィートではなく、デュースであることを意味していた..... –