我有一个文本文件,它有'
和"
形式的引用。此文本文件的格式为。
"string1", "string2", 'string3', 'string4', ''string5'', etc.
如何删除所有的引号'
和"
,同时保留文件的其余部分?
我想应该是这样的:
with open('input.txt', 'r') as f, open('output.txt', 'w') as fo:
for line in f:
fo.write(line.strip())
其中line.strip()
以某种方式除去引号的字符串。还需要什么吗?
Tags:
你很接近。与其
str.strip()
,不如尝试str.replace()
:相关问题 更多 >
编程相关推荐