IOError:[Errno 2]多个xml文件中没有这样的文件或目录

2024-09-20 05:31:28 发布

您现在位置:Python中文网/ 问答频道 /正文

我的代码:

import xml.etree.ElementTree as ET
import sys

XS = '{http://pubchem.ncbi.nlm.nih.gov/pug_view}'

mols = {'CID_11249995','CID_11249995'}

molstring = str(mols);

tree = ET.fromstring(open('C:/Python27/xml/'+ molstring +'.xml','r'))

root = tree.getroot( )

print(root)

这将产生以下错误:

Traceback (most recent call last): File "C:\Users\HENRY\Desktop\prac1.py", line 6, in tree = ET.fromstring(open('C:/Python27/xml/'+ molstring +'.xml','r')) IOError: [Errno 2] No such file or directory: "C:/Python27/xml/set(['CID_11249995', 'CID_11249995']).xml"


Tags: 代码importtreeasrootxmlopenet