擅长:python、mysql、java
<p>对于第一部分,请尝试以下代码:</p>
<pre><code>my_List= []
for root, dirs, files in os.walk(path):
for names in files:
if names.endswith(".dcm"):
my_List.append(os.path.join(root, names ))
</code></pre>
<p>对于编写部分,是的,实际上您的函数看起来有点多余,实际上您可以使用python CSV writer。
请在此处使用CSV编写器:<a href="https://docs.python.org/2/library/csv.html" rel="nofollow">https://docs.python.org/2/library/csv.html</a></p>