前提・実現したいこと
パイソンのテキストファイルの読み込み後の改行の\を削除する方法
今以下のテキストファイル(TextB.txt)
を読み込もうとしています。
It is meaningless only to think my long further aims idly.
It is important to set my aims but at the same time I should confirm
my present condition.
発生している問題・エラーメッセージ
読み込んだあとどうしても改行の/が残ってしまいます。
It is meaningless only to think my long further aims idly./ It is important to set my aims but at the same time I should confirm/ my present condition./
これを以下のような/がない形にしたいのですが。。。
It is meaningless only to think my long further aims idly.It is important to set my aims but at the same time I should confirm my present condition.
該当のソースコード
以下のコードを実行しました。 f = open('TextB.txt') data1 = f.read() f.close() print(data1)
試したこと
re.sub関数やreplace関数で/を指定してみたのですがどうしてもなくなりません。
補足情報(FW/ツールのバージョンなど)
ここにより詳細な情報を記載してください。
回答2件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2018/12/01 02:16