因此,我尝试用python搜索并替换vcxproj文件中的xml关键字runcodealysis。 我对python还很陌生,所以要温柔一点,但我认为这是最简单的语言来做这种事情。 我阅读了一些类似的示例,并得出了下面的代码,但是无论我搜索ElementTree Find调用,总是返回None。在
from xml.etree import ElementTree as et
xml = '''\
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Protected_Debug|Win32'">
<RunCodeAnalysis>false</RunCodeAnalysis>
</PropertyGroup>
</Project>
'''
et.register_namespace('', "http://schemas.microsoft.com/developer/msbuild/2003")
tree = et.ElementTree(et.fromstring(xml))
print(tree.find('.//RunCodeAnalysis'))
{a在线示例:^ a1的简化代码
谁能告诉我我做错了什么吗?在
好吧。。所以@ThomWiggers帮我解决了缺失的部分,这是我的最后一段代码。还没有参数检查或任何类型的智能,但它需要两个参数-文件名和是否将静态代码分析转换为true或false。我有大约30个项目,我想打开它为夜间建设,但真的不想打开它,因为它只是太慢了。在
相关问题 更多 >
编程相关推荐