Python_ Syntax error: unexpected character after line continuation character
Reason: the content of the written file is incorrect and should be processed as a string
>>> import os >>> os.makedirs(time_year+"\\"+time_month+"\\"+time_day)#where time_year, time_month, time_day are all variables with assigned values >>> os.chdir(time_year\time_month\time_day)# The problem is here, it's not written correctly File "<stdin>", line 1 os.chdir(time_year\time_month\time_day) ^ SyntaxError: unexpected character after line continuation character
This is OK: os.chdir (time_ year+”\\”+time_ month+”\\”+time_ day)
Refer to the writing method of creating directory in the first line
>>> os.chdir(time_year+"\\"+time_month+"\\"+time_day)#Correct >>> with open(time_hours+".txt", "w+") as fp:#This method will go to the next step normally ... fp.read() ...