扭转ids

时间:2013-01-08 08:41:33

标签: python

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

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

1 个答案:

答案 0 :(得分:1)

这将处理从下到上的行:

for line in reversed(list(open(timedir + "/gerrit_ids.txt"))):
    ...