Python SyntaxError: unexpected character after line continuation character

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)#time_year、time_month、time_day
>>> os.chdir(time_year\time_month\time_day)#Wrong
  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)#Right
>>> with open(time_hours+".txt","w+") as fp:
...     fp.read()
...

Similar Posts: