teratail header banner
teratail header banner
質問するログイン新規登録

回答編集履歴

2

f

2018/11/30 06:19

投稿

tiitoi
tiitoi

スコア21960

answer CHANGED
@@ -3,7 +3,7 @@
3
3
 
4
4
  ```python
5
5
  with open('TextB.txt') as f:
6
- lines = a.splitlines() # 改行で分割する。
6
+ lines = f.read().splitlines() # 改行で分割する。
7
7
  text = ' '.join(lines) # 空白で結合する。
8
8
  print(text)
9
9
  ```

1

d

2018/11/30 06:19

投稿

tiitoi
tiitoi

スコア21960

answer CHANGED
@@ -3,8 +3,7 @@
3
3
 
4
4
  ```python
5
5
  with open('TextB.txt') as f:
6
- data = ''
7
- for line in f.read().splitlines():
6
+ lines = a.splitlines() # 改行で分割する。
8
- data += line
7
+ text = ' '.join(lines) # 空白で結合する。
9
- print(data)
8
+ print(text)
10
9
  ```