indentation 相关问题

缩进用于通过指示块,闭包,条件和其他构造来组织代码。它使代码更易于阅读,并且在某些语言中用于处理控制流。

用于编辑文件的 Emacs 模式,其中缩进意味着结构

我想在 Emacs 中编辑一个又大又多的 YAML 文件。 文件结构由缩进隐含:如果 A 行缩进 10 个空格,则 A 开始一个包含以下所有缩进行的部分...

回答 3 投票 0

如何启用 Neovim 对 C 文件的缩进

缩进适用于 Java 和 Python,但不适用于 C: 初始化.vim 文件: 设置鼠标=a 设置编码=utf-8 设定数量 设置无交换文件 设置滚动=7 设置退格=缩进,结束,开始 设置剪贴板+=

回答 2 投票 0

Neovim 在 C 文件中的缩进根本不起作用

看到缩进在除 C 之外的 Java 和 Python 中完美地工作,这很奇怪。视频准确地展示了我正在谈论的内容。这是我的 init.vim 文件: 设置鼠标=a 设置编码=utf-8 设置 n...

回答 1 投票 0

在降价中显示图像并缩进

我有这样的事情: 我希望图像与“higklmn”段落相关联。 但图像无法正常显示。 请帮忙

回答 1 投票 0

如何使用Python缩进xml的特定行?

我有2个xml文件。 第一个看起来像这样: 我有 2 个 xml 文件。 第一个看起来像这样: <?xml version="1.0" encoding="UTF-8"?> <gmd:MD_Metadata xmlns:gmd="http://www.isotc211.org/2005/gmd" xmlns:gts="http://www.isotc211.org/2005/gts" xmlns:gmx="http://www.isotc211.org/2005/gmx" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:gml="http://www.opengis.net/gml" xmlns:gfc="http://www.isotc211.org/2005/gfc" xmlns:gco="http://www.isotc211.org/2005/gco" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:geonet="http://www.fao.org/geonetwork" xsi:schemaLocation="http://www.isotc211.org/2005/gmd http://www.isotc211.org/2005/gmd/gmd.xsd"> <gmd:identificationInfo> <gmd:MD_DataIdentification> <gmd:citation> <gmd:CI_Citation> <gmd:identifier> <gmd:MD_Identifier> <gmd:code> <gco:CharacterString>blabla</gco:CharacterString> </gmd:code> </gmd:MD_Identifier> </gmd:identifier> <gmd:date> <gmd:CI_Date> <gmd:date> <gco:Date>date</gco:Date> </gmd:date> <gmd:dateType> <gmd:CI_DateTypeCode codeList="http://standards.iso.org/ittf/PubliclyAvailableStandards/ISO_19139_Schemas/resources/Codelist/ML_gmxCodelists.xml#CI_DateTypeCode" codeListValue="creation"> blabla </gmd:CI_DateTypeCode> </gmd:dateType> </gmd:CI_Date> </gmd:date> <gmd:edition> <gco:CharacterString>6</gco:CharacterString> </gmd:edition> <gmd:editionDate> <gco:DateTime>date</gco:DateTime> </gmd:editionDate> <gmd:title> <gco:CharacterString>blabla</gco:CharacterString> </gmd:title> </gmd:CI_Citation> </gmd:citation> <gmd:abstract> <gco:CharacterString>blabla</gco:CharacterString> </gmd:abstract> <gmd:pointOfContact> <gmd:CI_ResponsibleParty> <gmd:organisationName> <gco:CharacterString>blabla</gco:CharacterString> </gmd:organisationName> <gmd:contactInfo> <gmd:CI_Contact> <gmd:address> <gmd:CI_Address> <gmd:electronicMailAddress> <gco:CharacterString>blabla</gco:CharacterString> </gmd:electronicMailAddress> <gmd:country> <gco:CharacterString/> </gmd:country> </gmd:CI_Address> </gmd:address> </gmd:CI_Contact> </gmd:contactInfo> </gmd:CI_ResponsibleParty> </gmd:pointOfContact> <gmd:descriptiveKeywords> <gmd:MD_Keywords> <gmd:keyword> <gco:CharacterString>blabla</gco:CharacterString> </gmd:keyword> <gmd:keyword> <gco:CharacterString>blabla</gco:CharacterString> </gmd:keyword> <gmd:keyword> <gco:CharacterString>blabla</gco:CharacterString> </gmd:keyword> <gmd:keyword> <gco:CharacterString>blabla</gco:CharacterString> </gmd:keyword> <gmd:keyword> <gco:CharacterString>blabla</gco:CharacterString> </gmd:keyword> </gmd:MD_Keywords> </gmd:descriptiveKeywords> <gmd:topicCategory> <gmd:MD_TopicCategoryCode>blabla</gmd:MD_TopicCategoryCode> </gmd:topicCategory> <gmd:extent> <gmd:EX_Extent> <gmd:description> <gco:CharacterString>blabla</gco:CharacterString> </gmd:description> <gmd:geographicElement> <gmd:EX_GeographicBoundingBox> <gmd:westBoundLongitude> <gco:Decimal>0</gco:Decimal> </gmd:westBoundLongitude> <gmd:eastBoundLongitude> <gco:Decimal>0</gco:Decimal> </gmd:eastBoundLongitude> <gmd:southBoundLatitude> <gco:Decimal>0</gco:Decimal> </gmd:southBoundLatitude> <gmd:northBoundLatitude> <gco:Decimal>0</gco:Decimal> </gmd:northBoundLatitude> </gmd:EX_GeographicBoundingBox> </gmd:geographicElement> </gmd:EX_Extent> </gmd:extent> <gmd:spatialResolution> <gmd:MD_Resolution> <gmd:distance> <gco:Distance uom="-"/> </gmd:distance> <gmd:equivalentScale> <gmd:MD_RepresentativeFraction> <gmd:denominator> <gco:Integer>blabla</gco:Integer> </gmd:denominator> </gmd:MD_RepresentativeFraction> </gmd:equivalentScale> </gmd:MD_Resolution> </gmd:spatialResolution> <gmd:resourceSpecificUsage> <gmd:MD_Usage> <gmd:specificUsage> <gco:CharacterString/> </gmd:specificUsage> </gmd:MD_Usage> </gmd:resourceSpecificUsage> <gmd:resourceConstraints> <gmd:MD_SecurityConstraints> <gmd:useLimitation> <gco:CharacterString>blabla</gco:CharacterString> </gmd:useLimitation> <gmd:classification> <gmd:MD_ClassificationCode codeListValue="restricted_FR">blabla</gmd:MD_ClassificationCode> </gmd:classification> </gmd:MD_SecurityConstraints> <gmd:MD_Constraints> <gmd:useLimitation> <gco:CharacterString/> </gmd:useLimitation> </gmd:MD_Constraints> </gmd:resourceConstraints> <gmd:resourceConstraints> <gmd:MD_LegalConstraints> <gmd:useLimitation> <gco:CharacterString/> </gmd:useLimitation> <gmd:accessConstraints> <gmd:MD_RestrictionCode codeListValue="restricted" codeList="http://standards.iso.org/ittf/PubliclyAvailableStandards/ISO_19139_Schemas/resources/codelist/ML_gmxCodelists.xml#MD_RestrictionCode"/> </gmd:accessConstraints> <gmd:useConstraints> <gmd:MD_RestrictionCode codeList="http://standards.iso.org/ittf/PubliclyAvailableStandards/ISO_19139_Schemas/resources/codelist/ML_gmxCodelists.xml#MD_RestrictionCode" codeListValue="restricted"/> </gmd:useConstraints> <gmd:otherConstraints> <gco:CharacterString> blabla </gco:CharacterString> </gmd:otherConstraints> </gmd:MD_LegalConstraints> </gmd:resourceConstraints> <gmd:resourceSpecificUsage> <gmd:MD_Usage> <gmd:specificUsage> <gco:CharacterString/> </gmd:specificUsage> </gmd:MD_Usage> </gmd:resourceSpecificUsage> </gmd:MD_DataIdentification> </gmd:identificationInfo> <gmd:referenceSystemInfo> <gmd:MD_ReferenceSystem> <gmd:referenceSystemIdentifier> <gmd:RS_Identifier> <gmd:code> <gco:CharacterString>blabla</gco:CharacterString> </gmd:code> </gmd:RS_Identifier> </gmd:referenceSystemIdentifier> </gmd:MD_ReferenceSystem> </gmd:referenceSystemInfo> <gmd:distributionInfo> <gmd:MD_Distribution> <gmd:distributionFormat> <gmd:MD_Format> <gmd:name> <gco:CharacterString>blabla</gco:CharacterString> </gmd:name> <gmd:version> <gco:CharacterString>blabla</gco:CharacterString> </gmd:version> </gmd:MD_Format> </gmd:distributionFormat> </gmd:MD_Distribution> </gmd:distributionInfo> <gmd:contact> <gmd:CI_ResponsibleParty> <gmd:organisationName> <gco:CharacterString>blabla</gco:CharacterString> </gmd:organisationName> </gmd:CI_ResponsibleParty> </gmd:contact> <isAvailableAsPaper>blabla</isAvailableAsPaper> <productKind>blabla</productKind> <visibility>blabla</visibility> </gmd:MD_Metadata> 第二个看起来像这样: <?xml version="1.0" encoding="UTF-8"?> <metadataDefault> <visibility>blabla</visibility> <domain>L</domain> <catalogueEntitySubType>blabla</catalogueEntitySubType> <dataType1>01_blabla</dataType1> <dataType2>01-01_blabla</dataType2> <dataType3>01-01-1_blabla</dataType3> <isPermanent>true</isPermanent> <pointOfContact>blabla</pointOfContact> <author>blabla</author> <authorCountry>blabla</authorCountry> <rawMetaDataProfile>blabla</rawMetaDataProfile> </metadataDefault> 我想将第二个 xml 中的标签添加到第一个 xml 的末尾,而无需下载其他库。 我已经设法使用 xml.etree.ElementTree 做到这一点,但添加的第一个标签没有正确的缩进。 我的Python代码如下: import xml.etree.ElementTree as et # Saves the namespaces (xmlns) of the first XML for re-application to the output et.register_namespace('gmd', "http://www.isotc211.org/2005/gmd") et.register_namespace('gts', "http://www.isotc211.org/2005/gts") et.register_namespace('gmx', "http://www.isotc211.org/2005/gmx") et.register_namespace('xsi', "http://www.w3.org/2001/XMLSchema-instance") et.register_namespace('gml', "http://www.opengis.net/gml") et.register_namespace('gfc', "http://www.isotc211.org/2005/gfc") et.register_namespace('gco', "http://www.isotc211.org/2005/gco") et.register_namespace('xlink', "http://www.w3.org/1999/xlink") et.register_namespace('geonet', "http://www.fao.org/geonetwork") # Analyse the XML file xml_produit = et.parse('first_xml.xml') xml_general = et.parse('second_xml.xml') # Obtain the root element of the first XML root_produit = xml_produit.getroot() print("La balise racine est :", root_produit) # Force display of unused namespaces not displayed with et.register_namespace in the root tag root_produit.set("xmlns:gts", "http://www.isotc211.org/2005/gts") root_produit.set("xmlns:gmx", "http://www.isotc211.org/2005/gmx") root_produit.set("xmlns:gml", "http://www.opengis.net/gml") root_produit.set("xmlns:gfc", "http://www.isotc211.org/2005/gfc") root_produit.set("xmlns:xlink", "http://www.w3.org/1999/xlink") root_produit.set("xmlns:geonet", "http://www.fao.org/geonetwork") # Obtain the root element of the second XML root_general = xml_general.getroot() print("La balise racine est :", root_general) # Get the child tags of the second XML from the 2nd to the last one sub_elements=root_general[1:] print("Les balises enfant de la racine sont :", sub_elements) for elements in sub_elements: root_produit.append(elements) # Copies the child tags into the first XML #et.indent(elements[0], '\t', level=1) # An indentation test with et.indent (not working) xml_produit.write("infodump.xml", encoding='utf-8', xml_declaration=True, method='xml') # Write a new XML that combines the two #EDIT tree = ET.parse('infodump.xml') ET.indent(tree, space=" ") tree.write("infodump2.xml", encoding='utf-8', xml_declaration=True, method='xml') 我得到了什么: <gmd:contact> <gmd:CI_ResponsibleParty> <gmd:organisationName> <gco:CharacterString>blabla</gco:CharacterString> </gmd:organisationName> </gmd:CI_ResponsibleParty> </gmd:contact> <isAvailableAsPaper>blabla</isAvailableAsPaper> <productKind>blabla</productKind> <visibility>blabla</visibility> <domain>L</domain> <catalogueEntitySubType>Blabla</catalogueEntitySubType> <dataType1><dataType1>01_blabla</dataType1> <dataType2>01-01_blabla</dataType2> <dataType3>01-01-1_blabla</dataType3> <isPermanent>true</isPermanent> <pointOfContact>blabla</pointOfContact> <author>blabla</author> <authorCountry>blabla</authorCountry> <rawMetaDataProfile>blabla</rawMetaDataProfile> </gmd:MD_Metadata> 我想要实现的目标: <gmd:contact> <gmd:CI_ResponsibleParty> <gmd:organisationName> <gco:CharacterString>blabla</gco:CharacterString> </gmd:organisationName> </gmd:CI_ResponsibleParty> </gmd:contact> <isAvailableAsPaper>blabla</isAvailableAsPaper> <productKind>blabla</productKind> <visibility>blabla</visibility> <domain>L</domain> <catalogueEntitySubType>Blabla</catalogueEntitySubType> <dataType1><dataType1>01_blabla</dataType1> <dataType2>01-01_blabla</dataType2> <dataType3>01-01-1_blabla</dataType3> <isPermanent>true</isPermanent> <pointOfContact>blabla</pointOfContact> <author>blabla</author> <authorCountry>blabla</authorCountry> <rawMetaDataProfile>blabla</rawMetaDataProfile> </gmd:MD_Metadata> 我在互联网上搜索并尝试了 et.indent 但我无法得到我想要的。 任何帮助将不胜感激。 我总是使用大写 ET 来表示 xml.etree.ElementTree。 ET.indent() 函数应该可以工作(et 我仅用于 lxml,但它应该可以同等工作)。根据您的情况,请尝试: tree = et.ElementTree(xml_produit) et.indent(tree, space=" ") tree.write("infodump.xml", encoding='utf-8', xml_declaration=True, method='xml')

回答 1 投票 0

缩进 GNU 风格如何在 VIM 中正常运行?

我写的函数如下: 静态整型 foo_bar(const char *字符串) { } 当我使用 Vim 缩进时,它会执行以下操作: 静态整型 foo_bar(const char *字符串) { } 它增加了一些额外的水疗...

回答 2 投票 0

Qt Creator 中的缩进指南?

是否可以告诉 Qt Creator 中的编辑器(我使用的是 V.4.9.2)显示一些“缩进指南”,例如 C++Builder(默认)、Notepad++(默认)或 Visual Studio(通过插入)? 我的意思是

回答 2 投票 0

eslint 缩进错误“预期缩进 2 个空格,但发现了 4 个。”,角度 14

我在角度14中使用“eslint”:“^8.23.0” 当我使用 "eslint": "^8.22.0" 时一切正常,更新到 8.23.0 后出现以下错误: 我的es...

回答 3 投票 0

RStudio 中的缩进问题

和许多其他人一样,我喜欢在多行上编写代码,并且我很欣赏 RStudio 提供的自动缩进功能。当代码编辑器中出现“未定义”一词时,问题突然开始了

回答 2 投票 0

为什么我的正则表达式无法找到错误的缩进?

我工作的编码标准使用这个括号缩进: 一些声明 { 东西=其他东西; }; 控制结构、功能等() { 更多东西; 对于(一定量的时间...

回答 4 投票 0

如何在Geany中自定义缩进

基于geany文档 Geany 知道四种类型的自动缩进: 无:完全禁用自动缩进。 基本:在新行上添加与 l...

回答 1 投票 0

为什么我的 Perl 脚本没有从我的正则表达式匹配中找到错误的缩进

我工作的编码标准使用这个括号缩进: 一些声明 { 东西=其他东西; }; 控制结构、功能等() { 更多东西; 对于(一定量的时间...

回答 5 投票 0

如何缩进项目符号ppt vba

我在 PPT 文件文本框中的 VBA 中出现项目符号问题。 我使用以下代码来修改项目符号中的现有文本: PptDoc.Slides(3).Shapes(3).TextFrame.TextRange.Text = "1" & ...

回答 2 投票 0

你会如何解析缩进(Python风格)?

如何定义解析器和词法分析器规则来解析使用缩进定义范围的语言。 我已经用谷歌搜索并找到了一种通过生成 INDEN 来解析它的巧妙方法...

回答 2 投票 0

Python:尝试创建一个解析和求和函数以便稍后调用

正如标题所述,我正在尝试创建(def)一个函数,其中导入 re ,然后解析字符串(使用正则表达式)以将数字添加到列表末尾。我知道代码

回答 1 投票 0

复制粘贴时VS代码缩进混乱

为什么在 VScode 中复制粘贴代码时缩进总是乱七八糟? 例如: 复印: 粘贴: 另一个例子: 有时甚至更混乱。 有没有办法...

回答 2 投票 0

编号后在 Jupyter Notebook 中的“markdown”单元格中缩进标题

我正在尝试对 Jupyter Notebook 中的标题进行编号。然而,这看起来很丑陋,因为空格的大小当然取决于字体大小。 我正在寻找一种方法来制作......

回答 1 投票 0

在 emacs 中移动区域或行

我正在 emacs 中寻找一种将文本向右或向左移动 n 个空格的方法。与 vim 中的功能类似 << or >>。它应该适用于一个区域,或者如果没有选择区域...

回答 4 投票 0

VSC 在换行符上放入一定量的空格作为缩进级别

我刚刚设置了 Visual Studio 代码,以便我的 Python 代码使用制表符进行缩进。现在,当我按 Enter 键时,VSC 不再放入正确数量的制表符以保持缩进,而是...

回答 3 投票 0

如何让eclipse不自动缩进代码块

我喜欢 Eclipse 的自动缩进功能,但有时我有一些缩进,我不希望它纠正,比如 audioBuffer1[j] = (短) (VOLUME_REDUCER * ( inputBuffer[i] + 阿尔...

回答 4 投票 0

最新问题
© www.soinside.com 2019 - 2024. All rights reserved.