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

回答編集履歴

4

list化

2019/12/04 08:57

投稿

peperoncino000
peperoncino000

スコア148

answer CHANGED
@@ -4,10 +4,10 @@
4
4
  12.758,540.856
5
5
  12.759,540.857"""
6
6
 
7
- split_texts = map(lambda x: x.split(','), text_box1.split('\n'))
7
+ split_texts = list(map(lambda x: x.split(','), text_box1.split('\n')))
8
8
  # split_texts = []
9
9
  # for s in text_box1.split('\n'): #=> 改行コードで分割
10
- # split_texts.append(s.split(',') #=> カンマで分割
10
+ # split_texts.append(s.split(',')) #=> カンマで分割
11
11
 
12
12
 
13
13
  result = []

3

無駄な内包表記削除

2019/12/04 08:57

投稿

peperoncino000
peperoncino000

スコア148

answer CHANGED
@@ -4,8 +4,12 @@
4
4
  12.758,540.856
5
5
  12.759,540.857"""
6
6
 
7
- split_texts = [[i for i in j] for j in map(lambda x: x.split(','), text_box1.split('\n'))]
7
+ split_texts = map(lambda x: x.split(','), text_box1.split('\n'))
8
+ # split_texts = []
9
+ # for s in text_box1.split('\n'): #=> 改行コードで分割
10
+ # split_texts.append(s.split(',') #=> カンマで分割
8
11
 
12
+
9
13
  result = []
10
14
  for i in range(len(split_texts[0])):
11
15
  r = []

2

元データ追加

2019/12/04 08:55

投稿

peperoncino000
peperoncino000

スコア148

answer CHANGED
@@ -1,4 +1,9 @@
1
1
  ```python
2
+ text_box1 = """12.730,540.827
3
+ 12.733,540.830
4
+ 12.758,540.856
5
+ 12.759,540.857"""
6
+
2
7
  split_texts = [[i for i in j] for j in map(lambda x: x.split(','), text_box1.split('\n'))]
3
8
 
4
9
  result = []

1

typo

2019/12/04 08:00

投稿

peperoncino000
peperoncino000

スコア148

answer CHANGED
@@ -4,8 +4,8 @@
4
4
  result = []
5
5
  for i in range(len(split_texts[0])):
6
6
  r = []
7
- for text in split_texts:
7
+ for texts in split_texts:
8
- r.append(text[i])
8
+ r.append(texts[i])
9
9
  result.append(r)
10
10
 
11
11
  print(result)