How can I remove the last character of a string in python?
This question already has an answer here:
 As you say, you don't need to use a regex for this.  You can use rstrip .  
my_file_path = my_file_path.rstrip('/')
 If there is more than one / at the end, this will remove all of them, eg '/file.jpg//' -> '/file.jpg' .  From your question, I assume that would be ok.  
The easiest is
as @greggo pointed out
string="mystring";
string[:-1]
你可以使用String.rstrip 。 
result = string.rstrip('/')
上一篇: 在Python中打印字符串的特定部分
