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 175 views
2 answers 271 views
2 answers 278 views
1 answer 181 views
1 answer 217 views
...