For example, a method is passed a path as a parameter, this path might be “C:/a/b/c/d”, what if I want to use os.chdir() to change to C:/a/b/c (without the last folder)? Can os.chdir() take the “..” command?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
os.chdir()can take'..'as argument, yes. However, Python provides a platform-agnostic way: by usingos.pardir: