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 90 views
2 answers 124 views
2 answers 144 views
1 answer 83 views
1 answer 109 views
...