I get errno 22 with this code:
import datetime
now = str(datetime.datetime.now())
filename = "log_{}".format(now)
logFile = open(filename, "w+")
I get errno 22 with this code:
import datetime
now = str(datetime.datetime.now())
filename = "log_{}".format(now)
logFile = open(filename, "w+")
Quick fix if you are okay with : being replaced by .:
import datetime
now = str(datetime.datetime.now())
filename = "log_{}".format(now).replace(':', '.')
filename
# 'log_2018-09-13 11.39.42.216000'
logFile = open(filename, "w+")
It is an issue with the filename containing ":" characters.