python xyz_python中xyz坐标的欧几里德距离

使用生成器表达式的简单解决方案From PEP 289 Generator Expressions

Rationale

Experience with list comprehensions has shown their widespread utility

throughout Python. However, many of the use cases do not need to have a full list created in memory. Instead, they only need to iterate over the elements one at a time.

因为你不需要保存中间结果

可能你有一个大的数据集

以及itertools标准库模块中的^{},因为您需要计算数据集中每对有趣的点的距离。在$ cat euclid.py

from scipy.spatial.distance import euclidean

from itertools import combinations

lines = ['HETATM 1 H10 XSHQ 0 10.139 2.231 0.091 1.00 0.00 H',

'HETATM 2 N1 XSHQ 0 9.641 1.386 -0.104 1.00 0.00 N',

'HETATM 3 H9 XSHQ 0 9.773 1.133 -1.063 1.00 0.00 H',

'HETATM 4 C1 XSHQ 0 8.245 1.531 0.230 1.00 0.00 H']

H_lines = (line for line in lines if line[-1]=='H')

H_lists = (line.split() for line i

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值