[新手上路]批处理新手入门导读[视频教程]批处理基础视频教程[视频教程]VBS基础视频教程[批处理精品]批处理版照片整理器
[批处理精品]纯批处理备份&还原驱动[批处理精品]CMD命令50条不能说的秘密[在线下载]第三方命令行工具[在线帮助]VBScript / JScript 在线参考
返回列表 发帖
python也没有很方便
  1. from itertools import combinations
  2. with open('a.txt', 'r') as f:
  3.     a = f.readlines()
  4. for i in combinations(range(len(a[0].strip())), 4):
  5.     n = ''.join([a[0][j] for j in i])
  6.     with open(n + '.txt', 'w') as f:
  7.         f.writelines(map(lambda x: ''.join([x[j] for j in i]) + '\n', a))
复制代码
拼回来
  1. import os
  2. import re
  3. a = {}
  4. for i in os.listdir('.'):
  5.     if re.match(r'\d+\.txt', i):
  6.         with open(i, 'r') as f:
  7.             t = f.readlines()
  8.             for j in range(len(t[0].strip())):
  9.                 if i[j] in a:
  10.                     continue
  11.                 a[i[j]] = list(map(lambda x: x[j], t))
  12. k = sorted([i for i in a.keys()])
  13. with open('b.txt', 'w') as f:
  14.     f.writelines(map(lambda y:''.join(y) + '\n', zip(*map(lambda x:a[x], k))))
复制代码
1

评分人数

TOP

返回列表