How to remove string trailing path separator in Python

1 Answer

0 votes
path = "example/path/project/"

cleaned_path = path.rstrip("/")

print(cleaned_path)



'''
run:

example/path/project

'''

 



answered Jun 16, 2025 by avibootz

Related questions

1 answer 97 views
2 answers 132 views
2 answers 159 views
1 answer 92 views
1 answer 118 views
...