读取文件时获取oserror未能加载外部实体

2024-04-18 16:37:19 发布

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

我尝试使用XMLDiff->;Diff\u files属性来识别两个XML文件之间的差异。我得到以下错误:

读取文件“File1.xml”时出错,无法加载外部实体“File2.xml”

下面是我的代码:

def FileCompare (golden_path,golden_File,Output_path,Output_File):

    try:
        gold_file=golden_File
        Out_file = Output_File
        gold_path=golden_path +"\\"+golden_File 
        Out_path =Output_path +"\\"+Output_File

        print('Files being compared', gold_file, Out_file)
        result = main.diff_files(gold_file, Out_file, 
                                         formatter=formatting.XMLFormatter())
        print (result)

    except:
        print(traceback.format_exc())
        pass

我检查了文件的权限,但具有完全访问权限。所以不知道为什么它会给我这个错误。你知道吗


Tags: 文件path权限output错误filesxmlresult
1条回答
网友
1楼 · 发布于 2024-04-18 16:37:19

欢迎使用stackoverflow。你知道吗

根据错误消息,File1.xml包含一个无法读取的文件File2.xml。因此File2.xml它要么是丢失的,要么在工作的相对位置上,要么是您正在比较的File1.xml文件,因此已经被锁定等等

相关问题 更多 >