import os path="c:\users\personal\AppData\Local\Programs\Python\Python36\srinu.txt" os.chdir(path) retval=os.getcwd() print("Directory changed successfully %s" %retval)here iam getting the unicodec codescope error syntax error how can i resolve it?
ere iam getting the unicodec codescope error syntax error how can i resolve it?
ere iam getting the unicodec codescope error syntax error how can i resolve it?
|
Sep-12-2017, 03:15 PM
import os
path="c:\users\personal\AppData\Local\Programs\Python\Python36\srinu.txt" os.chdir(path) retval=os.getcwd() print("Directory changed successfully %s" %retval)
Sep-12-2017, 03:25 PM
What's the error you're getting? Please share the entire traceback.
Sep-12-2017, 03:35 PM
(This post was last modified: Sep-12-2017, 03:36 PM by srinivas135.)
File "C:/Users/Personal/AppData/Local/Programs/Python/Python36/os.chdir().py", line 3, in <module>
os.chdir(path) OSError: [WinError 123] The filename, directory name, or volume label syntax is incorrect: 'c:\\users\\personal\\AppData\\Local\\Programs\\Python\\Python36\r.txt' iam getting this error even i have the file name r.txt >>> s = 'c\u' Traceback (most recent call last): File "<interactive input>", line 1 SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 1-2: truncated \uXXXX escapeFor path in Windows never single \ because of escape character.Turn all around / is a simple way to fix it and remember.>>> s = 'c/u' >>> s 'c/u' |
|
Users browsing this thread: 2 Guest(s)