加载路径前符号的含义(./,../,/)
导入OS模块
import OS
返回当前工作目录
os.getcwd()
print("当前工作目录为:{}".format(os.getcwd())) # 返回当前工作目录
将当前工作目录更改为 path
print("切换前的当前工作目录为:{}".format(os.getcwd())) # 返回当前工作目录
dst_path="/root" # 目标文件夹
os.chdir(dst_path) # 将当前工作目录切换为/root
print("切换后的当前工作目录为:{}".format(os.getcwd())) # 返回当前工作目录
除非将当前工作目录用chdir换了,其他情况用(./)都代表当前py文件所在的文件夹,也就是当前工作目录