首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在Python中生成STIX时的警告消息

在Python中生成STIX时的警告消息
EN

Stack Overflow用户
提问于 2015-10-12 16:40:42
回答 1查看 711关注 0票数 1

当运行一个简单的例子时,我会得到一个警告,我找不到原因。

代码语言:javascript
复制
from stix.core import STIXPackage, STIXHeader   # Import the STIX Package and STIX Header APIs

stix_package = STIXPackage()                    # Create an instance of STIXPackage
stix_header = STIXHeader()                      # Create an instance of STIXHeader
stix_header.description = "Getting Started!"    # Set the description
stix_package.stix_header = stix_header          # Link the STIX Head to our STIX Package

print(stix_package.to_xml())                    # print the XML for this STIX Package

结果在

C:\Python27\Lib\site-packages\stix\utils\deprecated.py:40: UserWarning:已经不推荐使用这个字段了。收到'str‘对象。warnings.warn(msg)

代码语言:javascript
复制
<stix:STIX_Package
        xmlns:cybox="http://cybox.mitre.org/cybox-2"
        xmlns:cyboxCommon="http://cybox.mitre.org/common-2"
        xmlns:cyboxVocabs="http://cybox.mitre.org/default_vocabularies-2"
        xmlns:example="http://example.com"
        xmlns:stix="http://stix.mitre.org/stix-1"
        xmlns:stixCommon="http://stix.mitre.org/common-1"
        xmlns:stixVocabs="http://stix.mitre.org/default_vocabularies-1"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" id="example:Package-7e8da451-3a23-47dd-b2e1-8646200dadf0" version="1.2">
    <stix:STIX_Header>
        <stix:Description>Getting Started!</stix:Description>
    </stix:STIX_Header>
</stix:STIX_Package>

小贴士

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2015-10-12 19:51:13

不推荐使用description字段,这可以在文档中看到,我在这里为后人复制该字段:

代码语言:javascript
复制
class stix.core.stix_header.STIXHeader(package_intents=None, description=None, handling=None, information_source=None, title=None, short_description=None)
Bases: stix.base.Entity

The STIX Package Header.

Parameters: 
handling – The data marking section of the Header.
information_source – The InformationSource section of the Header.
package_intents – DEPRECATED. A collection of VocabString defining the intent of the parent STIXPackage.
description – DEPRECATED. A description of the intent or purpose of the parent STIXPackage.
short_description – DEPRECATED. A short description of the intent or purpose of the parent STIXPackage.
title – DEPRECATED. The title of the STIXPackage.

我不知道他们为什么还没有更新他们的示例代码。

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/33086145

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档