【发布时间】:2016-01-27 03:59:13
【问题描述】:
我想尝试打开一个文件,找到一个特定字符串的索引(S_N)然后寻找位置并在下面写一些东西。
我正在使用代码...
C1 = open("Class 1.txt", "a")
pos = C1.find(S_N)
C1.seek(pos)
C1.write(correct)
每次我使用它时,python都会抛出这个错误......
Traceback (most recent call last):
File "C:\Users\eddie\Documents\HOMEWORK!!!!\11c\Computing Science\controlled assessment help\task3\task 3 official.py", line 41, in <module>
pos = C1.find(S_N)
AttributeError: '_io.TextIOWrapper' object has no attribute 'find'
为什么这不起作用????
【问题讨论】:
-
好吧,因为
'_io.TextIOWrapper' object has no attribute 'find',S_N是什么?那个文件内容是什么?
标签: python text-files