function GetDelimiteredStringN(Astring:String;Dlmter:Char;nPos:integer):string; var sList:TStringList; begin Result:=''; sList:=TStringList.Create; sList.Text:=StringReplace(Astring,Dlmter,#13#10,[rfReplaceAll]); if (nPos>0) and (sList.Count>=
最近写毕业设计遇到一个问题,就是我从一个txt文件中逐个读取字符,并修改其中的内容后存到另一个txt文件中,如下图:
字符替换规则是把所有的0转化为1,把所有的255转化为0。当然程序里面需要遍历好多次,算法复杂度相当差,但还是实现了初衷,源码如下:
import os
with open((os.path.join('test.txt')), 'r') as f:
data=f.readlines()
for line in data:
odom=line.split()
nu