我试图逐行读取文件,对于我读取的每一行,我尝试将其拆分,然后我想将它写在我得到它的地方。为了做到这一点,我写了这样一个代码:
fst_file=open(fst_text,"r+")
line=fst_file.readline()
while line:
temp=(line.split('CONFIG_',1)[1]).split('PATH=')
temp[1]=temp[1].replace('\n','')
fst_file.write(temp)
line=fst_file.readline()
fst_file.close()
但是我收到了如下错误:
File "test.py", line 84, in <module>
branchName()
File "test.py", line 75, in branchName
fst_file.write(temp)
TypeError: expected a character buffer object
有人帮我吗?