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

标签 python deprecation-warning

运行一个简单的示例时,我收到一条警告,我找不到原因。

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)

<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>

感谢提示

最佳答案

description 字段已被弃用,如 docs 中所示。 ,我在这里为后代复制:

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.

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

关于python - 在Python中生成STIX时的警告消息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33086145/

相关文章:

javascript - getCurrentPosition() 和 watchPosition() 在不安全的来源上被弃用

python - scikit learn中的预处理-单个样本-折旧警告

warnings - jsonschema:向架构添加警告/弃用

node.js - 弃用警告 : Listening to events on the Db class has been deprecated and will be removed in the next major version

c# - 与 Python 相比,C# 中的 OpenCV MatchTemplate 太慢了

python - 为 3D 形状着色

python - 音频可视化

python - 加载环境以运行 Python 脚本的成本是多少?

python - Python 中的示例函数 : counting words

reactjs - React 16.7 - React.SFC 现已弃用