【问题标题】:print(sample_set.add('1232')) gives out put as Noneprint(sample set.add('1232')) 输出为 None
【发布时间】:2020-10-25 06:53:21
【问题描述】:

sample_set ={'a', 1234, 'xyz', 12.454} 打印(sample_set.add('1232'))

输出为:无

我想了解的是,为什么嵌套的 '.add' 函数不起作用并打印带有附加元素 1232 的集合?

【问题讨论】:

标签: python function printing


【解决方案1】:

因为add 方法没有返回任何内容。

只需进行以下更改:

sample_set ={'a', 1234, 'xyz', 12.454}
sample_set.add('1232')
print(sample_set)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2022-07-12
    • 1970-01-01
    • 2022-11-15
    • 2022-12-20
    • 1970-01-01
    • 2017-08-19
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多