0
Why the replace method doesn't work?
I'm trying to rename a string from "name.ttml.txt" to "name.srt.txt" the problem is that the replace method doesn't work. str = "name.ttml.txt" newstr = str.replace('.ttml', '.srt') print(str) print(newstr) The two outputs are the same, it appears that the method doesn't work.
3 Respostas
+ 4
The outputs were different when I ran the code in the Playground, and it worked as expected. Could you please save it in the Playground and share a link so we can see what's going on?
Also, I'd recommend not using str as a variable name, as it's also a built-in function as well as a data type.
+ 1
Oh I see, I was playing around on visual studio. Now I used an online interpreter and worked as expected.
Can you suggest me an easier to use ide for python on windows?
+ 1
That's strange! I just ran it on VS Code, and it gave me the expected output. What version of Python are you using? Could you please try it again after using a variable name other than str?
Regarding Python IDE on Windows, I'm afraid I can't help you there. As you can see, I currently use VS Code myself. Before that I had used Emacs for a long time, which takes a while to get used to.