python - 在 Python 中循环遍历数字

标签 python linux

我需要遍历两个列表,每个列表都包含整数。

我应该使用什么函数来循环遍历 Python 中的 2 个列表?我在 Linux 机器上工作。

最佳答案

听起来你没有正确使用 scp - 见https://unix.stackexchange.com/questions/188285/how-to-copy-a-file-from-a-remote-server-to-a-local-machine

根据远程机器可用的内容,您可以在那里运行脚本并获得结果;这可能更有效。

您对要执行的实际操作含糊不清;如果你想快速处理大量数据,NumPy 可能真的有帮助——比如

import numpy as np

FILES = ["a.dat", "b.dat"]    # we assume that all files are the same length

data = np.stack(
    (np.fromfile(f, dtype=np.uint32) for f in FILES),   # endian-ness may be an issue!
    axis=1
)

# applying a Python function
def myfunc(row):
    return min(row)
result = np.apply_along_axis(myfunc, 1, data)

# but using a numpy function directly would be better!
result = np.min(data, axis=1)

关于python - 在 Python 中循环遍历数字,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44656695/

相关文章:

java - 如何在 Linux 中从下载的源代码创建 Java 包

linux - Makefile.PL - 没有这样的文件或目录

python - centralWidget 大小似乎错误?

java - Word XML 到 RTF 转换

python - 在这种情况下,Python 如何避免无限递归?

python - 如何访问作为列表的 Pandas 系列元素

python - 解释 3D 数组在内存中的间距、宽度、高度、深度

python - 比较随机和urandom

linux - 在查找命令中排除子路径

linux - 如何使用 ffmpeg 从管道和磁盘连接视频文件?