|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
f1 = open("F:/something.txt")
f2 = open("F:/poetry.txt")
str1 = []
str2 = []
for each_line in f1:
str1.append(each_line)
for each_line in f2:
str2.append(each_line)
length = len(str1)
f = open("F:/difference.txt","w")
for i in range(length):
if str1[i] != str2[i]:
string = ("第",i,"行不一样")
f.wtritelines(string)
f.close()
f = open("F:/difference.txt")
f.read()
AttributeError Traceback (most recent call last)
<ipython-input-8-e82872c8ac30> in <module>
14 if str1[i] != str2[i]:
15 string = ("第",i,"行不一样")
---> 16 f.wtritelines(string)
17 f.close
18
AttributeError: '_io.TextIOWrapper' object has no attribute 'wtritelines'
这样试试:
- f1 = open("F:/something.txt")
- f2 = open("F:/poetry.txt")
-
- str1 = []
- str2 = []
- for each_line in f1:
- str1.append(each_line)
- for each_line in f2:
- str2.append(each_line)
-
- length = len(str1)
- f = open("F:/difference.txt","w")
- for i in range(length):
- if str1[i] != str2[i]:
- string = ("第",i,"行不一样")
- f.writelines(string)
- f.close()
-
- f = open("F:/difference.txt")
- f.read()
复制代码
|
|