如何在Python中设置当前工作目录?
import os
print os.getcwd() # Prints the current working directory
设置工作目录。
os.chdir('c:\\Users\\uname\\desktop\\python') # Provide the new path here
人们使用熊猫包装
import os
import pandas as pd
tar = os.chdir('<dir path only>') # do not mention file name here
print os.getcwd()# to print the path name in CLI
下面的语法将用于在python CLI中导入文件
dataset(*just a variable) = pd.read_csv('new.csv')
它也适用于Mac
import os
path="/Users/HOME/Desktop/Addl Work/TimeSeries-Done"
os.chdir(path)
检查工作目录
os.getcwd()