もっと詳しく

連載目次 from pathlib import Path # ファイルの名前変更 foo = Path(‘foo.txt’) foo.touch() bar = Path(‘bar.txt’) bar.touch() # 存在しないファイルの名前に変更 baz = foo.rename(‘baz.txt’) print(baz) # baz.txt:renameメソッドは変更後のファイルのパスを返す # 既存のファイルの名前に変更 …