English 中文(简体)
原文:无此类档案或目录错误
原标题:python: no such file or directory error
import xlrd
book = xlrd.open_workbook("univ_list.xls")

I m New to python. 我试图阅读一个与我的书本相同的MS外壳。 上面的编码给我一个<代码>没有这种文档或目录错误。

如果需要,我将提供更多信息。

<<>Edit:在提出请求时有充分途径的代码

import xlrd
book = xlrd.open_workbook("D:Python_Scriptsuniv_list.xls")

相应错误信息

“enterography

最佳回答
import xlrd
book = xlrd.open_workbook("univ_list.xls")

除非我需要用xlsx替换xls,否则工作非常顺利。

问题回答

你通过扼杀越狱而再次受到伤害。

固定装置要么通过改道“D:Python_gustsuniv_list.xls”,要么将脚str改为r”(即D:Python_castsuniv_list.xls”),要么将脚.改为“r”>(即:D:Python_formsuniv_list.xls>)。

如果说你找不到档案,就应该采取两步步骤。 首先是确保档案存在。 第一步是确保正确阐明。 然后,正如AdamKG所建议的那样,确保金星能够看到:

import os.path 
assert os.path.isfile(path_to_file)

将<条码><>>/代码>改为<条码><>/条码>或<条码><>/条码>。

import xlrd
book = xlrd.open_workbook("D:/Python_Scripts/univ_list.xls")
 # book = xlrd.open_workbook("D:\Python_Scripts\univ_list.xls")

问题是,Pyer的版本含有目前的目录。 这并不是您的 ex或金字档案的目录(这很可能是你的家,c:或者Pyscriper的董事(使用os.getcwd()来掌握情况)。

因此,固定办法是为了提供全部途径——但正如其他答复和评论所示,这需要作为视窗的原始形式加以扼杀,而这种使用与在座标中使用作为逃生特性的节目编排方式不相称。





相关问题
Can Django models use MySQL functions?

Is there a way to force Django models to pass a field to a MySQL function every time the model data is read or loaded? To clarify what I mean in SQL, I want the Django model to produce something like ...

An enterprise scheduler for python (like quartz)

I am looking for an enterprise tasks scheduler for python, like quartz is for Java. Requirements: Persistent: if the process restarts or the machine restarts, then all the jobs must stay there and ...

How to remove unique, then duplicate dictionaries in a list?

Given the following list that contains some duplicate and some unique dictionaries, what is the best method to remove unique dictionaries first, then reduce the duplicate dictionaries to single ...

What is suggested seed value to use with random.seed()?

Simple enough question: I m using python random module to generate random integers. I want to know what is the suggested value to use with the random.seed() function? Currently I am letting this ...

How can I make the PyDev editor selectively ignore errors?

I m using PyDev under Eclipse to write some Jython code. I ve got numerous instances where I need to do something like this: import com.work.project.component.client.Interface.ISubInterface as ...

How do I profile `paster serve` s startup time?

Python s paster serve app.ini is taking longer than I would like to be ready for the first request. I know how to profile requests with middleware, but how do I profile the initialization time? I ...

Pragmatically adding give-aways/freebies to an online store

Our business currently has an online store and recently we ve been offering free specials to our customers. Right now, we simply display the special and give the buyer a notice stating we will add the ...

Converting Dictionary to List? [duplicate]

I m trying to convert a Python dictionary into a Python list, in order to perform some calculations. #My dictionary dict = {} dict[ Capital ]="London" dict[ Food ]="Fish&Chips" dict[ 2012 ]="...