Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
次の for および if 条件、for ループの後に if 条件がありますが、それらを 1 行にまとめる方法について何か提案はありますか?
for x in ids: if x!=12345
for x in (i for i in ids if i!=12345): # do stuff In [37]: ids Out[37]: [12343, 12344, 12345, 12346, 12347, 12348] In [38]: for x in (i for i in ids if i!=12345): ....: print x ....: 12343 12344 12346 12347 12348