A problem about File path encode
Kevien Lee
ironpythonster at gmail.com
Mon Oct 9 21:14:55 EDT 2006
Hi everyone,
There is a problem about File path encode ,when i want to parse an xml
file.
The code as follow:
------------------------------------------------------------------
from xml.dom import minidom
def ReadXml():
xmldoc=minidom.parse("D:\Downloads\1.xml")
print xmldoc.toxml()
if __name__ == "__main__":
ReadXml()
--------------------------------------------------------------------------
there throw an error:
Traceback (most recent call last):
File "D:/Downloads/test", line 8, in <module>
ReadXml()
File "D:/Downloads/test", line 4, in ReadXml
xmldoc=minidom.parse("D:\Downloads\1.xml")
File "D:\Program Files\Python25\lib\xml\dom\minidom.py", line 1913, in
parse
return expatbuilder.parse(file)
File "D:\Program Files\Python25\lib\xml\dom\expatbuilder.py", line 922, in
parse
fp = open(file, 'rb')
IOError: [Errno 2] No such file or directory: 'D:\\Downloads\x01.xml'
------------------------------------------------------------------------------------------
See the red line.the file path"D:\Downloads\1.xml" auto changed
'D:\\Downloads\x01.xml'
I think may be the version cause the problem (version2.4) at the beginning,but
when i changed the version2.5 ,
the error still exist.and the code run on another PC is OK.Why this error
happen?how could i fix that?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20061010/de757c19/attachment.html>
More information about the Python-list
mailing list