質問編集履歴
1
追記
title
CHANGED
File without changes
|
body
CHANGED
@@ -17,4 +17,25 @@
|
|
17
17
|
```
|
18
18
|
これを試したのですが、for data in inputfile
|
19
19
|
のところで、UnsupportedOperation: not readable というエラーが表示されていしまいます。
|
20
|
-
どこが原因なのでしょうか?
|
20
|
+
どこが原因なのでしょうか?
|
21
|
+
|
22
|
+
追記
|
23
|
+
```python
|
24
|
+
from glob import glob
|
25
|
+
import codecs
|
26
|
+
import re
|
27
|
+
import os
|
28
|
+
os.chdir("C:/Users/name/Documents/Python")
|
29
|
+
os.getcwd()
|
30
|
+
folder = glob("*")
|
31
|
+
for folders in folder :
|
32
|
+
for inputfilename in os.listdir(folders):
|
33
|
+
with open(folders+'/'+inputfilename, 'r', encoding='UTF-8') as inputfile:
|
34
|
+
for data in inputfile:
|
35
|
+
data = inputfile.read()
|
36
|
+
data = re.sub(r'\n', r'', data)
|
37
|
+
with open(folders+'/'+inputfilename, 'w', encoding='UTF-8') as outputfile:
|
38
|
+
outputfile.write(data)
|
39
|
+
```
|
40
|
+
これで実行できました。
|
41
|
+
もっとスマートにできる等の意見があればよろしくお願いします。
|