[python] How can I remove the last character of a string in python?

I have a file path as a string and trying to remove the last '/' from the end.

my_file_path = '/home/ro/A_Python_Scripts/flask-auto/myDirectory/scarlett Johanson/1448543562.17.jpg/'

I've been trying it with regex but it just keeps removing all the '/'. Is there any easier way to just remove the last character without regex?

This question is related to python regex string

The answer is


The easiest is

as @greggo pointed out

string="mystring";
string[:-1]

Similar questions with python tag:

Similar questions with regex tag:

Similar questions with string tag: