我需要遍历两个列表,每个列表都包含整数。
我应该使用什么函数来循环遍历 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/