回答編集履歴
1
追記
test
CHANGED
@@ -21,3 +21,31 @@
|
|
21
21
|
|
22
22
|
|
23
23
|
あと、numberの略ならnumでは?
|
24
|
+
|
25
|
+
|
26
|
+
|
27
|
+
ついでに
|
28
|
+
|
29
|
+
---
|
30
|
+
|
31
|
+
変数の値の文字列への埋め込みは、実はもっと簡単に書けます。
|
32
|
+
|
33
|
+
```Python
|
34
|
+
|
35
|
+
with open(f'test{i}.{extension}', 'w') as f:
|
36
|
+
|
37
|
+
f.write('test')
|
38
|
+
|
39
|
+
```
|
40
|
+
|
41
|
+
|
42
|
+
|
43
|
+
ただしPythonのバージョンが3.5以前ならば、こう書かねばなりません。
|
44
|
+
|
45
|
+
```Python
|
46
|
+
|
47
|
+
with open('test{}.{}'.format(i, extension), 'w') as f:
|
48
|
+
|
49
|
+
f.write('test')
|
50
|
+
|
51
|
+
```
|