Python converting '\' to '\\'

后端 未结 5 1194
耶瑟儿~
耶瑟儿~ 2021-01-27 16:46

I am writing a program to sort a list fo input strings (song names). Those songnames contains latex chars like $\\lambda$, which i want to get sorted like \'lambda\' instead, s

5条回答
  •  长情又很酷
    2021-01-27 17:18

    This is the expected behaviour: as it is displaying the string stored in the list, and the double slashes means escaped slash. If you want to see the actual string, you should simply print that string, not the list. Try to append this line to your program:

    print (' '.join(mlist))
    

提交回复
热议问题