回答編集履歴
1
edit
test
CHANGED
@@ -63,3 +63,43 @@
|
|
63
63
|
print(target_files)
|
64
64
|
|
65
65
|
```
|
66
|
+
|
67
|
+
|
68
|
+
|
69
|
+
---
|
70
|
+
|
71
|
+
|
72
|
+
|
73
|
+
LinuxやMacならシェルに頑張っていただくこともできます。
|
74
|
+
|
75
|
+
|
76
|
+
|
77
|
+
```python
|
78
|
+
|
79
|
+
import subprocess
|
80
|
+
|
81
|
+
run = subprocess.getoutput
|
82
|
+
|
83
|
+
|
84
|
+
|
85
|
+
search_words = input('input words: ').split()
|
86
|
+
|
87
|
+
path = '.'
|
88
|
+
|
89
|
+
|
90
|
+
|
91
|
+
target_files = run('ls {0} | grep -E "{1}"'.format(path, '|'.join(search_words))).split() # OR
|
92
|
+
|
93
|
+
|
94
|
+
|
95
|
+
print(target_files)
|
96
|
+
|
97
|
+
|
98
|
+
|
99
|
+
target_files = run('ls {0} | {1}'.format(path, ' | '.join(map('grep {0}'.format, search_words)))).split() # AND
|
100
|
+
|
101
|
+
|
102
|
+
|
103
|
+
print(target_files)
|
104
|
+
|
105
|
+
```
|