如何从字符串中删除某些字符?[Python]

xsa*_*boi 4 python string character

假设我有一个名为 cool 的字符串,cool 设置为“cool°”

cool = "cool°"
Run Code Online (Sandbox Code Playgroud)

如何从字符串中删除度数符号?

Dan*_*nez 6

由于字符串是不可变的,因此使用替换函数重新分配 cool

cool = "cool°"
cool = cool.replace("°","")
cool
'cool'
Run Code Online (Sandbox Code Playgroud)