Files

11 lines
289 B
Python
Raw Permalink Normal View History

2026-05-12 19:40:31 +09:00
import os
def write_to_file(str, filename):
# if the directory where the filename does not exist, create it
if not os.path.exists(os.path.dirname(filename)):
os.makedirs(os.path.dirname(filename))
with open(filename, "w") as f:
f.write(str)
f.close()