Python: How to Remove the Last Character from a String
You can use the slicing operation to remove the last character of a string in Python. Here's how to do it:
string = 'Hello World'
new_string = string[:-1]
print(new_string)
Output:
Hello Worl
This will remove the last character from the string.
原文地址: https://www.cveoy.top/t/topic/peTW 著作权归作者所有。请勿转载和采集!