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 に答える