c#和python哪个效率⾼_C#和Python的⼀个性能对⽐测试Python核⼼源代码:
if blkdat != []: # ⿊名单过滤
if buildhit == 'Y':
fhitblk = file(mainpath + 'b_' + outputfile, 'wb')
outdat = []
print '排序⿊名单...'
blkdat.sort()
print '过滤⿊名单...'
hitnum = 0
for a in xrange(len(orgdat)):
b = bisect_left(blkdat, orgdat[a])
if b>=len(blkdat) or blkdat[b] != orgdat[a]:
outdat.append(orgdat[a])
else:
hitnum = hitnum + 1
if buildhit == 'Y':
fhitblk.write(orgdat[a] + '\r\n')
print '被⿊名单过滤掉的号码总数为:', hitnum
if buildhit == 'Y':
fhitblk.close()
orgdat = outdat
C#核⼼源代码:
private void deal_Click(object sender, EventArgs e)
{
ArrayList org = new ArrayList();
ArrayList blk = new ArrayList();
StreamReader sr = new StreamReader(orgname);
StreamReader er = new StreamReader(blkname);
StreamWriter fr = new StreamWriter("");
string dat;
while ((dat = sr.ReadLine()) != null)
org.Add(dat.TrimEnd("\r\n".ToCharArray()));
while ((dat = er.ReadLine()) != null)
blk.Add(dat.TrimEnd("\r\n".ToCharArray())); blk.Sort();
int orglen = org.Count;
for (int a = 0; a < orglen; a++)
{
if (blk.BinarySearch(org[a]) < 0)
fr.WriteLine(org[a]);
}
fr.Close();
writeline和write的区别pythonMessageBox.Show("处理完毕!");
}

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。