我有一个像这样的numpy数组:
a = [[0.04393, 0.0, 0.0], [0.04393, 0.005, 0.0], [0.04393, 0.01, 0.0],[0.04393, 0.015, 0.0]]
我想在此格式化:
b = [((0.04393, 0.0, 0.0), ), ((0.04393, 0.005, 0.0), ), ((0.04393,
0.01, 0.0), ), ((0.04393, 0.015, 0.0), )]
我该怎么做?
答案 0 :(得分:3)
这样做:
a = [[0.04393, 0.0, 0.0], [0.04393, 0.005, 0.0], [0.04393, 0.01, 0.0],[0.04393, 0.015, 0.0]]
b = [ (tuple(a1),) for a1 in a]