我想将此脚本的输出打印到单独的文件中 . 这是我到目前为止的代码:

import os

from pathlib import Path
for path in Path('.').iterdir():
    print(path)