How do I using with open() as f: ... to write the file in a directory that doesn\'t exist.
with open() as f: ...
For example:
Make liberal use of the os module:
os
import os if not os.path.isdir('/Users/bill/output'): os.mkdir('/Users/bill/output') with open('/Users/bill/output/output-text.txt', 'w') as file_to_write: file_to_write.write("{}\n".format(result))