Oserror:[Errno 20] [英] Oserror: [Errno 20]

查看:176
本文介绍了Oserror:[Errno 20]的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是这个列表的新手,也是用python编程的。


我有一个错误:oserror [errno 20]不是目录" katiescint.py"


导致问题的代码是:

展开 | 选择 | Wrap < span class =codeDivider> | 行号

解决方案

< blockquote> kr fry写道:

我是这个列表的新手,也是用python编程的。

我有一个错误:oserror [errno 20]不是目录 ; katiescint.py"


请始终发布完整的追溯,而无需手动重新输入

数据。在大多数情况下,你会节省我们和你的大量时间和猜测。

导致问题的代码是:
[code]

os.listdir(DATADIR)中的subdir:#loop通过
字符串列表

file = FITS.Read(DATADIR +''/''+ subdir +''/ flux.fits'') #opens
flux.fits文件和读取



os.listdir()返回
$ b $内所有文件和目录的列表b目录指定(DATADIR),所以你不能假设subdir

总是会成为一个目录。使用os.path.isdir()确认它是
并忽略那些函数返回False的项目。


-Peter


对不起之前没有复制整个追溯,我跳了之后我已经完成了这个时间。

这次。


我现在得到:


回溯(最近一次调用最后一次):

文件" katiescint.py",第153行,在?

for osirpath.istdir(DATADIR):#loop through

字符串列表

AttributeError:''module''对象没有属性''istdir''


我的确认为它可能是listdir的意思。而不是istdir,但

也不起作用。

很抱歉是痛苦的。

Peter Hansen写道:

kr fry写道:

我是这个列表的新手,也是用python编程的。

我有一个错误:oserror [errno 20]不是目录" katiescint.py"



请始终发布完整的追溯,而无需手动重新输入数据。在大多数情况下,你会节省我们和你的大量时间和猜测。

导致问题的代码是:
[code]
<对于os.listdir(DATADIR)中的subdir:#loop通过
字符串列表

file = FITS.Read(DATADIR +''/''+ subdir +''/ flux。适合'')#opens
flux.fits文件和读取



os.listdir()返回指定的
目录中所有文件和目录的列表( DATADIR),所以你不能假设子目标总是会成为一个目录。使用os.path.isdir()确认它是
并忽略那些函数返回False的项目。

-Peter



kr fry开悟了我们:

我的确认为它可能是listdir的意思。而不是istdir,
但是这也不起作用。




你再也不告诉我们它是怎么回事我的工作。


从我们的角度思考你发布的内容。然后重新阅读,然后再次考虑
。只有当你确定我们能够完全理解它时,点击发送按钮。这将为我们节省大量的时间和价值,并且还可以更快地为您提供答案。


Sybren

-

世界的问题是愚蠢。并不是说应该对愚蠢的死刑进行处罚,但为什么我们不要仅仅拿掉

安全标签来解决问题呢? br />
Frank Zappa


Hi, I am new to this list and also programming with python.

I have an error: oserror [errno 20] not a directory "katiescint.py"

The piece of code causing the problem is:

Expand|Select|Wrap|Line Numbers

解决方案

k r fry wrote:

Hi, I am new to this list and also programming with python.

I have an error: oserror [errno 20] not a directory "katiescint.py"
Please always post complete tracebacks, and without manually reentering
the data. In most cases you''ll save us and you lots of time and guessing.
The piece of code causing the problem is:
[code]

for subdir in os.listdir(DATADIR): #loop through list of
strings

file=FITS.Read(DATADIR+''/''+subdir+''/flux.fits'') #opens
flux.fits file and reads



os.listdir() returns a list of all files and directories inside the
directory specified (DATADIR), so you can''t assume that "subdir" is
always going to be a directory. Use os.path.isdir() to confirm that it
is and ignore those items for which that function returns False.

-Peter


Sorry for not copying the whole traceback before, I hop I have done it
right this time.

I am now getting:

Traceback (most recent call last):
File "katiescint.py", line 153, in ?
for subdir in os.path.istdir(DATADIR): #loop through
list of strings
AttributeError: ''module'' object has no attribute ''istdir''

I did think maybe it was meant to be "listdir" instead of "istdir", but
that doesn''t work either.
Sorry to be a pain.
Peter Hansen wrote:

k r fry wrote:

Hi, I am new to this list and also programming with python.

I have an error: oserror [errno 20] not a directory "katiescint.py"


Please always post complete tracebacks, and without manually reentering
the data. In most cases you''ll save us and you lots of time and guessing.

The piece of code causing the problem is:
[code]

for subdir in os.listdir(DATADIR): #loop through list of
strings

file=FITS.Read(DATADIR+''/''+subdir+''/flux.fits'') #opens
flux.fits file and reads


os.listdir() returns a list of all files and directories inside the
directory specified (DATADIR), so you can''t assume that "subdir" is
always going to be a directory. Use os.path.isdir() to confirm that it
is and ignore those items for which that function returns False.

-Peter



k r fry enlightened us with:

I did think maybe it was meant to be "listdir" instead of "istdir",
but that doesn''t work either.



And again you don''t tell us in what way it doesn''t work.

Think about what you post from our point of view. Then re-read it, and
think about it again. Only if you''re sure that we''ll be able to fully
understand it, hit the ''send'' button. That will save us a lot of
guessting and asking, and will also get you your answer a lot faster.

Sybren
--
The problem with the world is stupidity. Not saying there should be a
capital punishment for stupidity, but why don''t we just take the
safety labels off of everything and let the problem solve itself?
Frank Zappa


这篇关于Oserror:[Errno 20]的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆