subprocess.Popen simple code does not allow me to perform a cd (change directory)

前端 未结 3 930
温柔的废话
温柔的废话 2020-12-06 12:24

I\'m trying to use a Python script to change directory, but I am getting an error.

The python code:

import subprocess
p = subprocess.Popen([\'cd\',         


        
3条回答
  •  爱一瞬间的悲伤
    2020-12-06 12:51

    You need to include all path with

    path = os.path.dirname('$0')
    currentpath = os.path.abspath(path)
    os.chdir(path)
    

提交回复
热议问题