改行文字、私のコードを削除できない理由を理解しようとしています:
def parsefile(f):
for line in open(f):
li=line.strip()
if not li.startswith("%"):
if not li.startswith(' '):
if not li.startswith('\n'):
print(line.replace("\n",""))
#print(line.rstrip())
「\ n」を無視するように指示したにもかかわらず、出力にスペースが残っています。これは次のようになります
type1
type2
type3
type4
あるべきとき
type1
type2
type3
type4
. 私の推測では、ループがスペースを離れることに関係しています。
アクセスしているファイルは次のとおりです。
%spam
type1
type2
type3
%spam
type4