Here is a functional code (create file with success)
sys.stdout = open(\'filename1.xml\', \'w\')
Now I\'m trying to name the file with the cu
Change this line
filename1 = datetime.now().strftime("%Y%m%d-%H%M%S")
To
filename1 = datetime.datetime.now().strftime("%Y%m%d-%H%M%S")
Note the extra datetime. Alternatively, change your import datetime to from datetime import datetime
datetime
import datetime
from datetime import datetime