【问题标题】:How do I to lose the results of running python in the form of an array (ex: array ([1, 2, ..., 6, 7, 8])如何以数组的形式丢失运行 python 的结果(例如:array ([1, 2, ..., 6, 7, 8])
【发布时间】:2018-10-17 04:10:23
【问题描述】:

示例数组: [数组([0.84312789, 0.75129959, 0.88778234, ..., 0.96588262, 0.98853215, 0.5203​​4823])]

我如何知道数组列表中 (...) 的值? 谢谢。

【问题讨论】:

    标签: arrays python-3.x arraylist


    【解决方案1】:

    您正在创建一个包含数组的列表,因此可以使用[0] 访问您的数组。

    您可以像访问列表元素一样访问数组中的元素。您还必须向 array 模块提供一个字符代码,用于描述数组中元素的类型。

    例子

    from array import array
    # 'd' describes double
    x = array('d', [0.84312789, 0.75129959, 0.88778234, 0.96588262, 0.98853215, 0.52034823])
    print(x[0][0])
    

    打印 0.84312789

    【讨论】:

    • 谢谢,但如果我使用(我将解释我的意思)示例:b = [array([0.84312789, 0.75129959, 0.88778234, ..., 0.96588262, 0.98853215, 0.5203​​4823])] a = array ('d' , [b]) print (a) or print (a [0] [0]) result is error -> TypeError: must be real number, not list the point 我想知道的值结果数组 (. ..) ?我怎样才能将列表更改为实数?谢谢
    猜你喜欢
    • 2021-10-23
    • 2011-09-08
    • 2021-02-23
    • 2017-03-19
    • 2022-10-08
    • 2021-05-30
    • 2021-02-15
    • 2021-07-01
    相关资源
    最近更新 更多