I am trying to check if folder exist if not the system create it and a JSON file will be written inside this folder.
The problem is that the system create an empty folder and displays this error:
None
the selected file is not readble because : [WinError 183] Cannot
create a file when that file already exists: './search_result'
'NoneType' object is not iterable
None
is the result of: print(searchResultFoder)
.
The code is:
if not(os.path.exists("./search_result")):
today = time.strftime("%Y%m%d__%H-%M")
jsonFileName = "{}_searchResult.json".format(today)
fpJ = os.path.join(os.mkdir("./search_result"),jsonFileName)
print(fpJ)
with open(fpJ,"a") as jsf:
jsf.write(jsondata)
print("finish writing")