Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我需要解析一个文件并提取到单个文件中。FileA 有 A 1 2 3 4 ,我需要创建内容为 A1、A2、A3 的单个文件...谢谢
主文件
一个 1 2 3 4
symbols = open('main.txt', 'r').readlines()[0].split() prefix = symbols[0] suffixes = symbols[1:] for suffix in suffixes: fileName = prefix + suffix + '.txt' f = open(fileName, 'w') f.write(prefix + suffix) f.close()
这是未经测试的