回答編集履歴

2

ブンポウ

2019/07/23 12:13

投稿

退会済みユーザー
test CHANGED
@@ -4,11 +4,11 @@
4
4
 
5
5
  with open(filepath, "r+" ...) as csvFile:
6
6
 
7
-   csvFile.seek(0)
8
-
9
7
    target = list(csvFile.read())
10
8
 
11
9
    target.insert(0, "入れたい文字列")
10
+
11
+   csvFile.seek(0)
12
12
 
13
13
    csvFile.write("".join(target))
14
14
 

1

修正

2019/07/23 12:13

投稿

退会済みユーザー
test CHANGED
@@ -4,9 +4,13 @@
4
4
 
5
5
  with open(filepath, "r+" ...) as csvFile:
6
6
 
7
- csvFile.seek(0)
7
+   csvFile.seek(0)
8
8
 
9
- csvFile.write()
9
+   target = list(csvFile.read())
10
+
11
+   target.insert(0, "入れたい文字列")
12
+
13
+   csvFile.write("".join(target))
10
14
 
11
15
 
12
16