擅长:python、mysql、java
<p>你可以试试这个:</p>
<pre><code>s = "orange"
list_of_fruits = ["apple", "banana", "orange"]
list_of_orange_things = ["carrot", "orange", "basketball"]
list_of_colors = ["orange", "green", "blue"]
new_list = [list_of_fruits, list_of_orange_things,list_of_colors]
final_list = [[b for b in i if b != s] for i in new_list]
</code></pre>
<p>输出:</p>
<pre><code>[['apple', 'banana'], ['carrot', 'basketball'], ['green', 'blue']]
</code></pre>
<p>这个基本算法迭代new_list中包含的列表并过滤掉任何出现的字符串s。但是正如@Willem Van Onsem所指出的,您需要找到一种存储列表的新方法,这样您就可以遍历每个人一次,比如列表中的列表。你知道吗</p>