【问题标题】:How select list based on last two characters of each element in python如何根据python中每个元素的最后两个字符选择列表
【发布时间】:2023-01-18 08:21:33
【问题描述】:

我有一个列表 aa=["tea","tee","t _N","tee _N"]。 我想获取最后两个字符为“_N”的元素。 结果类似于:["tea _N","tee _N"] 我怎么能这样做?谢谢!

【问题讨论】:

    标签: python python-3.x list


    【解决方案1】:
    list(filter(lambda x: x.endswith("_N"), aa))
    

    【讨论】:

      猜你喜欢
      • 2013-01-19
      • 2016-11-15
      • 2021-09-27
      • 1970-01-01
      • 2022-08-24
      • 1970-01-01
      • 2021-11-27
      • 2021-11-22
      • 2012-05-12
      相关资源
      最近更新 更多