
- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to remove all leading whitespace in string in Python?
The lstrip() method will remove leading whitespaces, newline and tab characters on a string beginning. You can use it in the following way:
>>> ' hello world!'.lstrip() 'hello world!'
You can also use the strip() function to remove both trailing and leading whitespace in the same manner. For example:
>>> ' hello world! '.strip() 'hello world!'
- Related Questions & Answers
- How to remove all trailing and leading whitespace in a string in Python?
- How to remove all trailing whitespace of string in Python?
- How to remove all whitespace from String in Java?
- Java Program to remove leading and trailing whitespace from a string
- How to remove leading and trailing whitespace in a MySQL field?
- Remove whitespace in Java string.
- How to remove leading and trailing whitespace from a MySQL field value?
- Python Pandas – Remove leading and trailing whitespace from more than one column
- Remove Leading Zeros From String in Java
- How to split string on whitespace in Python?
- Explain how to remove Leading Zeroes from a String in Java
- Remove Leading Zeros from a String in C#
- Add leading Zeros to Python string
- Remove All Adjacent Duplicates In String in Python
- Trim a string in Java to remove leading and trailing spaces
Advertisements