質問編集履歴

1

追記

2018/05/03 11:29

投稿

grx72expo
grx72expo

スコア15

test CHANGED
File without changes
test CHANGED
@@ -37,3 +37,45 @@
37
37
  のところで、UnsupportedOperation: not readable というエラーが表示されていしまいます。
38
38
 
39
39
  どこが原因なのでしょうか?
40
+
41
+
42
+
43
+ 追記
44
+
45
+ ```python
46
+
47
+ from glob import glob
48
+
49
+ import codecs
50
+
51
+ import re
52
+
53
+ import os
54
+
55
+ os.chdir("C:/Users/name/Documents/Python")
56
+
57
+ os.getcwd()
58
+
59
+ folder = glob("*")
60
+
61
+ for folders in folder :
62
+
63
+ for inputfilename in os.listdir(folders):
64
+
65
+ with open(folders+'/'+inputfilename, 'r', encoding='UTF-8') as inputfile:
66
+
67
+ for data in inputfile:
68
+
69
+ data = inputfile.read()
70
+
71
+ data = re.sub(r'\n', r'', data)
72
+
73
+ with open(folders+'/'+inputfilename, 'w', encoding='UTF-8') as outputfile:
74
+
75
+ outputfile.write(data)
76
+
77
+ ```
78
+
79
+ これで実行できました。
80
+
81
+ もっとスマートにできる等の意見があればよろしくお願いします。