How to delete a character from a string using Python

前端 未结 16 1402
耶瑟儿~
耶瑟儿~ 2020-11-22 16:35

There is a string, for example. EXAMPLE.

How can I remove the middle character, i.e., M from it? I don\'t need the code. I want to know:

16条回答
  •  悲哀的现实
    2020-11-22 17:20

    To replace a specific position:

    s = s[:pos] + s[(pos+1):]
    

    To replace a specific character:

    s = s.replace('M','')
    

提交回复
热议问题