我有一个清单:
Cat
Dog
Monkey
Pig
我有一个脚本:
import sys
input_file = open('list.txt', 'r')
for line in input_file:
sys.stdout.write('"' + line + '",')
输出是:
"Cat
","Dog
","Monkey
","Pig",
我想要:
"Cat","Dog","Monkey","Pig",
我无法摆脱处理列表中的行时出现的回车。最后摆脱 , 的奖励点。不知道如何找到并删除最后一个实例。