前提・実現したいこと
a.txtを読み取って、指定した文字を消してものをb.txtに移したいです。回答お願いします
発生している問題・エラーメッセージ
AttributeError: 'list' object has no attribute 'maketrans'
該当のソースコード
python
1myfile = open('a.txt', 'r', encoding="utf-8") 2all_lines = myfile.readlines() 3myfile.close() 4myfile = open('b.txt', 'w',encoding="utf-8") 5 myfile = all_lines.maketrans({ 6 ', りんご,みかん': ' ', 7 ', "b", "c"': ' ', 8 }) 9myfile.close()
試したこと
stripなどを使ったが、上のようなエラーコードがでる。
回答2件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2022/01/18 04:39