简体   繁体   English

Anaconda默认目录

[英]Anaconda default directory

pd.read_csv('C:\Users\aaa\Desktop\contrylist.csv')

plz help guys.I am a beginner in pandas..i am not able to open this csv files. 请帮助我。我是熊猫的初学者..我无法打开此csv文件。 Also I want to ask which is default directory for anacondas where I can store files and open them in below format 我也想问问哪一个是蟒蛇的默认目录,我可以在其中存储文件并以以下格式打开它们

pd.read_csv('contrylist.csv')

If you don't want to put the full path, the file needs to be in the current directory, which you can see from 如果您不想放置完整路径,则文件必须位于当前目录中,您可以从中查看

import os
os.path.abspath(os.path.curdir)

To change the current directory, use os.chdir 要更改当前目录,请使用os.chdir

os.chdir(r'C:\Users\aaa\Desktop')

By the way, if you use IPython, then you can just use %pwd to see the current directory and %cd to change it. 顺便说一句,如果您使用IPython,则只需使用%pwd查看当前目录,然后使用%cd进行更改。

Double your backslashes. 将您的反斜杠加倍。

pd.read_csv('C:\\Users\\aaa\\Desktop\\contrylist.csv')

Or use raw strings: 或使用原始字符串:

pd.read_csv(r'C:\Users\aaa\Desktop\contrylist.csv')

Backslash is a special character in string literals and it's used for escaping. 反斜杠是字符串文字中的特殊字符,用于转义。 You should read the docs: strings and string literals . 您应该阅读docs: 字符串字符串文字

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM