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:
- [Solved] SyntaxError: unexpected character after line continuation character
- MySQL from_ Unixtime() and UNIX_ The difference of timestamp() function
- Uncaught SyntaxError: Unexpected token o
- node env: node\r: No such file or directory
- How to Solve Python Syntax error: invalid character in identifier
- Non-ASCII character ‘\xe8’ in file xxx.py on line 8, but no encoding declared
- Python Exception: TypeError: write() argument must be str, not list
- Python Open File SyntaxError: (unicode error) ‘unicodeescape’ codec can’t decode bytes in …
- JAVA Error: Failed to convert property value of type ‘java.lang.String‘ to required type ‘java.util.Date
- node env: node\r: No such file or directory