如果我有文件:
A pgm1
A pgm2
A pgm3
Z pgm4
Z pgm5
C pgm6
C pgm7
C pgm8
C pgm9
如何创建列表:
[['pgm1','pgm2','pgm3'],['pgm4','pgm5'],['pgm6','pgm7','pgm8','pgm9']]
我需要保留加载文件中的原始顺序。所以[pgm4,pgm5]必须是第二个子列表。你知道吗
我的偏好是,当分组变量从上一个变量更改为“A,Z,C”时,会触发新的子列表。但是如果分组变量必须是连续的,我可以接受,即“1,2,3”。你知道吗
(这是为了支持同时运行每个子列表中的程序,但要等待所有上游程序完成后才能继续下一个列表。)
我正在使用python2.6.6运行rhel2.6.32
只需使用^{} 。你知道吗
代码:
演示:
blow代码执行与上述代码相同的操作,但保持顺序:
在我的操作之后,额外的网络搜索发现:How do I use Python's itertools.groupby()?
这是我目前的做法。请告诉我能不能让它更像Python。你知道吗
loadfile1.txt(无分组变量-输出与loadfile4.txt相同):
loadfile2.txt(随机分组变量):
loadfile3.txt(相同的分组变量-无依赖关系-多线程):
loadfile4.txt(不同的分组变量-依赖项-单线程):
我的Python脚本:
使用loadfile2.txt时输出:
相关问题 更多 >
编程相关推荐