使用 sublime text 3 在 python 3 中打开 xml 文件时出错 [英] Error when opening xml file in python 3 with sublime text 3

查看:60
本文介绍了使用 sublime text 3 在 python 3 中打开 xml 文件时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Traceback (most recent call last):
  File "C:\Users\diamo\Documents\Sublime Text Saves\ItunesDatabase.py", line 50, in <module>
    stuff = ET.parse(fname)
  File "C:\Users\diamo\AppData\Local\Programs\Python\Python35-32\lib\xml\etree\ElementTree.py", line 1183, in parse
    tree.parse(source, parser)
  File "C:\Users\diamo\AppData\Local\Programs\Python\Python35-32\lib\xml\etree\ElementTree.py", line 583, in parse
    source = open(source, "rb")
OSError: [Errno 22] Invalid argument: '\u202aC:/Users/diamo/Desktop/Library.xml'

我不明白为什么会这样.

I don't understand why this is happening.

以下是代码的基本部分:

Here is the essential bits of the code:

import sqlite3
import xml.etree.ElementTree as ET

conn = sqlite3.connect('trackdb.sqlite')
cur = conn.cursor()

fname = '‪C:/Users/diamo/Desktop/Library.xml'  #input('Music Data Filename: ')
if (len(fname) < 1): fname = 'C:/Users/diamo/Desktop/Library.xml'

stuff = ET.parse(fname)

请帮忙.

推荐答案

我找到了答案.我不确定它是如何到达那里的,但是当我在文本上逐条移动闪烁的垂直条时,我发现在所有单词之前我必须按两次才能使其移动,这意味着开头有一个字符不占用任何空间.我删除了它,现在我的程序正在运行.

I found the answer. I'm not sure how it got there but as I was moving my blinky vertical bar across the text piece by piece, I found that before all the words I had to press twice to make it move, meaning there was a character at the beginning not taking up any space. I deleted it and now my program is working.

这篇关于使用 sublime text 3 在 python 3 中打开 xml 文件时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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