在 vi 编辑器中打开我的输入文件就像
ACT211111011100000000000000000000000606018^\10421040036991^\M/S DOHAR TRADERS^\BD^\167^\050^\000000579300^\000000579300^\
ACT211111011100000000000000000000000606018^\16711010000040^\M/S RAKIB TRADERS^\BD^\167^\050^\000100200386^\000100200386^\
ACT211111011100000000000000000000000606018^\16711010000101^\M-S, OVI ENTERPRISE^\BD^\167^\050^\000000000000^\000000000000^\
ACT211111011100000000000000000000000606018^\16711010000110^\MS. PUSPALATA CONSTRUCTION^\BD^\167^\050^\000000117900^\000000117900^\
我想像这样拆分字符串
ACT211111011100000000000000000000000606018 10421040036991 M/S DOHAR TRADERS BD 167 050 000000579300 000000579300
在这里,我给出了我正在测试的代码
#!/usr/bin/python
import os
flag220 = 0
f=file("/oasis/ist75/tmp/aa","r").readlines()
linecount=len(f)-1
for i in range(linecount):
mycmds = []
index = linecount-i-1
line = f[index]
split_line = line.split()
print split_line[0]
if split_line[0].strip() == "ACT211111011100000000000000000000000606018":
j=index-1
flag220 = 0
while j>-1:
print f[j]
flag220 = 1
break
j=j-1
if flag220 == 1:
for j in range (len(split_line)):
if split_line[j]=='050':
value = split_line[j+1]
print value
mycmd = './balance.sh ' + value + split_line[1].strip()
mycmds.append(mycmd)
break
for x in range(len(mycmds)):
print mycmds[x]
os.system(mycmds[x])
mycmds=[]
print split_line[0]
输出看起来ACT21111101110000000000000000000000060601810421040036991M/S
不正确。请在这方面帮助我。