相关疑难解决方法(0)

在Python中真的有一个@运算符来计算点积吗?

这个答案是否正确:https://stackoverflow.com/a/39662710/1175080

引用那个答案.

在Python 3.5中,dot产品有一个新的运算符,所以你可以写一个= A @ B而不是a = numpy.dot(A,B)

它似乎对我不起作用.

$ python3
Python 3.6.1 (default, Apr  4 2017, 09:40:21) 
[GCC 4.2.1 Compatible Apple LLVM 8.1.0 (clang-802.0.38)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> a = [1, 2, 3]
>>> b = [4, 5, 6]
>>> a @ b
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: unsupported operand type(s) for @: 'list' and 'list'
>>>
Run Code Online (Sandbox Code Playgroud)

但是相关的答案已经获得了6个赞成票,所以我必须遗漏一些东西.您能否提供一个完整的示例,说明如何使用@ …

python operators

7
推荐指数
1
解决办法
2447
查看次数

Python:两个向量列表中每个向量的点积

说我有两个包含向量的列表:

A = [(1,1,1), (0,1,1)]
B = [(1,0,1), (1,0,0)]
Run Code Online (Sandbox Code Playgroud)

我希望在每个向量之间执行点积,以便输出为

C = [2, 0]
Run Code Online (Sandbox Code Playgroud)

如何在python中做到这一点?

python

4
推荐指数
2
解决办法
3706
查看次数

标签 统计

python ×2

operators ×1