使用 python 编辑文本文件中的行
我正在尝试创建一个文件列表,包括其完整地址。它们存储在 CERN 的网格文件访问库中,这意味着我使用 gfal-ls 访问它们,据我所知 gfal-find 不存在。
我当前的 python 2.7 代码是:
lscommand = "gfal-ls root://address/moreaddress/MyFiles | head -20 > MyListName.txt"
os.system(lsCommand)
它创建 MyListName.txt
如下:
file1.root
file2.root
...
file20.root
我现在想要做的是打开此列表并添加 root://address/moreaddress/MyFiles /
在每个文件名之前。
我怎样才能在Python中做到这一点?
I am trying to create a list of files including their full addresses. They're stored on the Grid File Access Library from CERN which means I access them using gfal-ls
, and as far as I know gfal-find
doesn't exist.
My current python 2.7 code is:
lscommand = "gfal-ls root://address/moreaddress/MyFiles | head -20 > MyListName.txt"
os.system(lsCommand)
which creates MyListName.txt
as so:
file1.root
file2.root
...
file20.root
What I now want to be able to do is to open this list and add root://address/moreaddress/MyFiles/
before each filename.
How can I do this in python?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我当前的解决方案如下所示:
My current solution looks like this: