IOError:[Errno 13]权限被拒绝: [英] IOError: [Errno 13] Permission denied:

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

问题描述

我已构建此代码来专门识别.XML文件的负载并从这些文件中提取坐标.这是我的代码:

I have built this code to specifically identify a load of .XML files and to extract co-ordinates from those files. Here is my code:

from xml.etree import ElementTree as ET
import sys, string, os, arcgisscripting
gp = arcgisscripting.create(9.3)

workspace = "D:/J040083"
gp.workspace = workspace

for root, dirs, filenames in os.walk(workspace): # returms root, dirs, and files
    for filename in filenames:
        filename_split = os.path.splitext(filename) # filename and extensionname (extension in [1])
        filename_zero = filename_split[0]
        extension = str.upper(filename_split[1])

        try:
            first_2_letters = str.upper(filename_zero[0] + filename_zero[1])
        except:
            first_2_letters = "XX"

        if first_2_letters == "LI" and extension == ".XML":
            tree = ET.parse(workspace)
            print tree.find('//{http://www.opengis.net/gml}lowerCorner').text
            print tree.find('//{http://www.opengis.net/gml}upperCorner').text

我遇到一个错误:

Message File Name   Line    Position    
Traceback               
    <module>    D:\J040083\TXT_EXTRACTION.py    32      
    parse   C:\Python25\Lib\xml\etree\ElementTree.py    862     
    parse   C:\Python25\Lib\xml\etree\ElementTree.py    579     
IOError: [Errno 13] Permission denied: 'D:/J040083'     

我绝对可以访问此文件夹!我也尝试过制作新的空文件夹,并在其中只放一个.xml文件,但是我遇到了同样的错误!有人知道出什么问题了吗?

I definitely do have access to this folder! I have also tried making new, empty folders and putting just one .xml file in there but i get the same error! Does anyone have any idea what has gone wrong?

推荐答案

您需要更改行

tree = ET.parse(workspace)

tree = ET.parse(filename)

因为工作空间是一个目录,而parse方法使用一个文件名.

because workspace is a directory and the parse method takes a filename.

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

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