0

我正在使用以下代码获取更改 ID,然后进行循环...我需要反转我在文件 change_ids.txt 中获得的 ID。我需要一些关于反转的最佳方法的想法?请提供您的想法.

with open(timedir + "/change_ids.txt", "wb") as f:
    check_call("ssh -p 29418 company.com "
        "gerrit query --commit-message --files --current-patch-set "
        "status:open project:platform/vendor/com-proprietary/code branch:master |"
        "grep refs |"
        "cut -f4 -d'/'",
            shell=True,   # need shell due to the pipes
            stdout=file)  # redirect to a file
 for line in open(timedir + "/change_ids.txt"):
#code

change_ids.txt 包含

210717
210716
210715
210714
210713
4

1 回答 1

1

这将从下到上处理行:

for line in reversed(list(open(timedir + "/gerrit_ids.txt"))):
    ...
于 2013-01-08T08:45:40.737 回答