Python os.listdir(path)是否包含特殊条目'';和'';?

Python os.listdir(path)是否包含特殊条目'';和'';?,python,python-2.7,pydev,Python,Python 2.7,Pydev,我试图访问的路径是。/Pictures/NewYork self.path = "../Pictures/NewYork" self.files = os.listdir(self.path ) 我收到一条错误消息说 The system cannot find the path specified: '../Pictures/NewYork/*.*' 有没有更好的升级方式?只是一个不速之客。。。你想从py文件所在的位置上去吗 os.listdir(“../Pictures/NewYork”

我试图访问的路径是
。/Pictures/NewYork

self.path = "../Pictures/NewYork"
self.files = os.listdir(self.path )
我收到一条错误消息说

The system cannot find the path specified: '../Pictures/NewYork/*.*'

有没有更好的升级方式?

只是一个不速之客。。。你想从py文件所在的位置上去吗

os.listdir(“../Pictures/NewYork”)
将相对于当前工作目录,该目录可以是任何内容

如果我的猜测是对的,那么你想要这个:

this_dir = os.path.dirname(__file__)
new_york_dir = os.path.join(this_dir, '..', 'Pictures', 'NewYork')
files = os.path.listdir(new_york_dir)

那不可能是你的密码。全球模式从何而来?以及。。是一个完全可以接受的路径,无需转换。
。/Pictures/NewYork
有效,前提是当前工作目录具有这样的同级目录。
os.getcwd()
的输出告诉您什么?@pvg:the
*.
来自,如果没有这样的目录,它不会被删除。@Random832,这会显示在错误消息中?可怕的