2017-06-20 132 views
0

我需要遍历两个包含整数的列表。在Python中循环遍历数字

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

+0

你到目前为止尝试过什么? –

+0

你对远程机器有什么样的访问权限?这是在网络共享上,还是通过http/ftp,或者你可以SSH? –

+0

你的Python脚本需要访问这些文件。 https://stackoverflow.com/questions/1035340/reading-binary-file-and-looping-over-each-byte – RPGillespie

回答

1

听起来像是你不使用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)