Skip to content

mkyong.com

  • Spring Boot
  • Java Virtual Threads
  • Contact
  1. Home /
  2. trim

Tag: trim

python August 15, 2019 1 min read by mkyong 0 comments

Python – How to trim a String?

In Python trim method is called strip, it removes the leading and trailing spaces of a String. str.strip() #trim str.lstrip() #ltrim str.rstrip() #rtrim #!/usr/bin/python str = " abc " print(str) print(str.strip()) print(str.lstrip()) print(str.rstrip()) Output {space} abc {space} abc abc {space} {space} abc References Python docs str.strip()

Read more Python – How to trim a String?

Java and Spring tutorials since 2008. Every example is a complete, runnable file, compiled and run on a real machine before it goes out.

About This Site

  • About
  • Editorial Policy
  • Contact
  • Code License
  • Privacy Policy
  • Terms of Use

© 2026 mkyong.com — Powered by WordPress

RSS