回答編集履歴
1
途中で投稿してしまいました。
answer
CHANGED
@@ -1,4 +1,28 @@
|
|
1
1
|
以下でできますが、変更しない方がよいというのはTakaiYさんのおっしゃる通りだと思います。
|
2
|
-
```
|
3
|
-
|
2
|
+
```python
|
3
|
+
>>> dicts = [
|
4
|
+
... {'translatedText': '1. Plug the power cord into an outlet.', 'detectedSourceLanguage': 'ja', 'input': '1. 電源コードのプラグをコンセントに差し込む。\n'},
|
5
|
+
... {'translatedText': '2. Press the power button.', 'detectedSourceLanguage': 'ja', 'input': '2.電源ボタンを押す。\n'},
|
6
|
+
... {'translatedText': 'The power lamp lights up.', 'detectedSourceLanguage': 'ja', 'input': '\u3000\u3000電源ランプが点灯します。\n'},
|
7
|
+
... {'translatedText': '3. Press the start button.', 'detectedSourceLanguage': 'ja', 'input': '3. 開始ボタンを押す。\n'},
|
8
|
+
... {'translatedText': 'The operating lamp lights up.', 'detectedSourceLanguage': 'ja', 'input': '\u3000\u3000稼働中ランプが点灯します。\n'},
|
9
|
+
... {'translatedText': '4. Press the stop button.', 'detectedSourceLanguage': 'ja', 'input': '4. 停止ボタンを押す。\n'},
|
10
|
+
... {'translatedText': 'Stop the operation.', 'detectedSourceLanguage': 'ja', 'input': '\u3000\u3000運転を停止します。\n'},
|
11
|
+
... {'translatedText': '5. Unplug the power coat from the outlet.', 'detectedSourceLanguage': 'ja', 'input': '5. 電 源コートのプラグをコンセントから抜く。\n'}]
|
12
|
+
>>>
|
13
|
+
>>> for i, d in enumerate(dicts):
|
14
|
+
... d.pop('detectedSourceLanguage')
|
15
|
+
... d[f'translatedText{i+1}'] = d.pop('translatedText')
|
16
|
+
... d[f'input{i+1}'] = d.pop('input')
|
17
|
+
...
|
18
|
+
'ja'
|
19
|
+
'ja'
|
20
|
+
'ja'
|
21
|
+
'ja'
|
22
|
+
'ja'
|
23
|
+
'ja'
|
24
|
+
'ja'
|
25
|
+
'ja'
|
26
|
+
>>> print(dicts)
|
27
|
+
[{'translatedText1': '1. Plug the power cord into an outlet.', 'input1': '1. 電源コードのプラグをコンセントに差し込む。\n'}, {'translatedText2': '2. Press the power button.', 'input2': '2.電源ボタンを押す。\n'}, {'translatedText3': 'The power lamp lights up.', 'input3': '\u3000\u3000電源ランプが点灯します。\n'}, {'translatedText4': '3. Press the start button.', 'input4': '3. 開始ボタンを押す。\n'}, {'translatedText5': 'The operating lamp lights up.', 'input5': '\u3000\u3000 稼働中ランプが点灯します。\n'}, {'translatedText6': '4. Press the stop button.', 'input6': '4. 停止ボタンを押す。\n'}, {'translatedText7': 'Stop the operation.', 'input7': '\u3000\u3000運転を停止します。\n'}, {'translatedText8': '5. Unplug the power coat from the outlet.', 'input8': '5. 電源コートのプラグをコンセントから抜く。\n'}]
|
4
28
|
```
|