我在 python 中运行这段代码

with open("test.txt", "r") as networkFile:
    for line in networkFile:
            src = line.split(,python,python-3.x,numpy"/>
	














首页 > 解决方案 > PYTHON 中的错误:TypeError:ufunc 'multiply' 不包含签名匹配类型 dtype('

我在 python 中运行这段代码

with open("test.txt", "r") as networkFile:
    for line in networkFile:
            src = line.split(

问题描述

我在 python 中运行这段代码

with open("test.txt", "r") as networkFile:
    for line in networkFile:
            src = line.split()[0]
            nodes.append(src)
nodesf = np.unique(nodes)

with open("test.txt", "r") as networkFile:
    for line in networkFile:
            src = line.split()[0]
            network.append([src])
edgesf = np.array(network)

avgDegree = (2 * edgesf) / nodesf
print("avgDegree: ",avgDegree)

并给我一行错误 avgDegree = (2 * edgesf) / nodesf

TypeError: ufunc 'multiply' did not contain a loop with signature matching types   
`dtype('<U4') dtype('<U4') dtype('<U4')`

任何想法?


Model.findOneAndUpdate(
            {
              _id: "document_id",
              "translation.language": "languageId",
            },
            {
              $set: {
                "translation.$.text: "text",
                "translation.$.active": "status",
                "translation.$.system.android" : true
            },
            { new: true, upsert: true, }
          )
          .lean();

标签: pythonpython-3.xnumpy

解决方案


推荐阅读