首页
学习
活动
专区
圈层
工具
发布

反转ids
EN

Stack Overflow用户
提问于 2013-01-08 16:41:33
回答 1查看 59关注 0票数 0

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

代码语言:javascript
复制
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包含

代码语言:javascript
复制
210717
210716
210715
210714
210713
EN

回答 1

Stack Overflow用户

发布于 2013-01-08 16:45:41

这将从下到上处理这些行:

代码语言:javascript
复制
for line in reversed(list(open(timedir + "/gerrit_ids.txt"))):
    ...
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/14211166

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档