This is the code I have so far, yes I know the 'dirs' code creates a folder, but I am not sure of the code (if there is one) to create a file instead!
import os
if os.path.isfile(outfile):
print("Name already used, please choose another")
else:
os.makedirs(outfile)
Any help would be appreciated :D
open(filename, 'w'), that will create a new file (or overwrite an existing one).isfile(path) == Falseimplicatesmakedirs(path). 3) Opening a file for writing creates the file if it does not exist yet. At least, this is how most operating systems behave, and this is how Python behaves on any supported platform.