Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
私はファイルを扱っており、それらを処理した後、1.txt、2.txt などの昇順の数値名で保存する必要があります。手動で私は以下のようにします:
Variable_1 = "C:\\1.txt" Variable_2 = "C:\\2.txt"
for i in range(10): filename = "C:\\%d.txt" % i with open(filename, 'a') as f: ....
これと同じくらい簡単ですが、ジェネレーターを使用してファイル名を作成することもできます (それはあなた次第です)