Removing character in list of strings

前端 未结 6 2166
清歌不尽
清歌不尽 2020-12-01 06:51

If I have a list of strings such as:

[(\"aaaa8\"),(\"bb8\"),(\"ccc8\"),(\"ffffdffffd8\")...]

What should I do in order to get rid of all the

6条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-01 07:23

    A faster way is to join the list, replace 8 and split the new string:

    mylist = [("aaaa8"),("bb8"),("ccc8"),("ffffdffffd8")]
    mylist = ' '.join(mylist).replace('8','').split()
    print mylist
    

提交回复
热议问题