Just open the file for writing and it will be created if it does not exist (if you have the correct permission to write to this place).
f = open('some_file_that_might_not_exist.txt', 'w')
f.write(data)
You will receive IOErrorif you cannot open the file for writing.
source
share