|
|

楼主 |
发表于 2020-4-10 15:32:46
|
显示全部楼层
非常感谢大佬的细心讲解,我已经将程序修改了在创建完file_3后,将指针指向开始位置,但是运行完了count还是0?您帮我看下我修改对吗,我是正确理解你的意思了吗
file_1=open("E:\\绝地求生\\python试用\\绝地求生手机号码1.txt")
file_2=open("E:\\绝地求生\\python试用\\长春.txt")
file_3 = open("E:\\绝地求生\\python试用\\绝地求生前7位.txt", "r+")
count=0
for each_line in file_1:
file_3.write(each_line[0:7])
file_3.write("\n")
file_1.close()
file_3.seek(0,0)
for each_1 in file_3:
for each_2 in file_2:
if each_1 == each_2:
count += 1
break
file_2.close()
file_3.close()
print(count)
|
|