擅长:python、mysql、java
<p>我发现了一个难看的解决方法,将trought传递给一个文件,因此首先我用python将数组写入一个文件:</p>
<pre><code>with open('/content/file_types.txt', 'w') as f:
for ft in file_types:
f.write(ft + '\n')
</code></pre>
<p>然后我在另一个单元格中从bash读取并使用它:</p>
<pre><code>%%bash
filename=/content/protected_file_types.txt
while IFS= read -r f;
do
find ./ -name "*.$f" -exec file {} ';' ;
done < $filename
</code></pre>
<p>这样我就不会像另一个<a href="https://stackoverflow.com/a/61713349/8069500">answer</a>的评论中建议的那样,在同一个单元格中混合使用bash和python</p>
<p>我希望找到一个更好的解决方案,可能使用一些我不知道的技巧</p>