回答編集履歴
2
ブンポウ
answer
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
ファイルのポインターを変えればいいのではないでしょうか。
|
2
2
|
```python
|
3
3
|
with open(filepath, "r+" ...) as csvFile:
|
4
|
-
csvFile.seek(0)
|
5
4
|
target = list(csvFile.read())
|
6
5
|
target.insert(0, "入れたい文字列")
|
6
|
+
csvFile.seek(0)
|
7
7
|
csvFile.write("".join(target))
|
8
8
|
|
9
9
|
```
|
1
修正
answer
CHANGED
@@ -1,8 +1,10 @@
|
|
1
1
|
ファイルのポインターを変えればいいのではないでしょうか。
|
2
2
|
```python
|
3
3
|
with open(filepath, "r+" ...) as csvFile:
|
4
|
-
|
4
|
+
csvFile.seek(0)
|
5
|
-
|
5
|
+
target = list(csvFile.read())
|
6
|
+
target.insert(0, "入れたい文字列")
|
7
|
+
csvFile.write("".join(target))
|
6
8
|
|
7
9
|
```
|
8
10
|
で先頭に書き込めますよ。
|