Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

stripping whitespace in python

greet = '      Hello Bob      '
# This is how we strip the whitespace at the beginning
print(greet.lstrip())       # Output: Hello Bob
                            # The whitespace at the end remains
# This is how we strip the whitespace at the end
print(greet.rstrip())       # Output:       Hello Bob
                            # The whitespace at the beginning remains
# This is how we strip the whitespaces at both the beginning and at the end
print(greet.strip())        # Output: Hello Bob
                            # White spaces at beginning and at end have removed
# But remember the initial string is not changed
print(greet)                # Output:       Hello Bob
Comment

stripping whitespace in python

greet = '      Hello Bob      '
# This is how we strip the whitespace at the beginning
print(greet.lstrip())       # Output: Hello Bob
                            # The whitespace at the end remains
# This is how we strip the whitespace at the end
print(greet.rstrip())       # Output:       Hello Bob
                            # The whitespace at the beginning remains
# This is how we strip the whitespaces at both the beginning and at the end
print(greet.strip())        # Output: Hello Bob
                            # White spaces at beginning and at end have removed
# But remember the initial string is not changed
print(greet)                # Output:       Hello Bob
Comment

PREVIOUS NEXT
Code Example
Python :: how to add user input for a question python 
Python :: dataframe rolling first eleemnt 
Python :: setting python2 in the path for npm install 
Python :: sort np list of string 
Python :: get object by name blender python 
Python :: print(f ) python 
Python :: find the median of input number in a list and print 
Python :: iterating with index in for loops python 
Python :: noob python 
Python :: python pip past 
Python :: how to use with statementin python 2.4 
Python :: get all permutations of string 
Python :: tuple methods in python 
Python :: change group box border color pyqt5 
Python :: python can you put try except in list comprehension 
Python :: # convert string to date 
Python :: from future import division 
Python :: 151 - Power Crisis solution 
Python :: create instances of a class in a for loop 
Python :: from sklearn.metrics import confusion_matrix pred = model.predict(X_test) pred = np.argmax(pred,axis = 1) y_true = np.argmax(y_test,axis = 1) 
Python :: validating credit card numbers 
Python :: how to divide string in python 
Python :: Python - Comment lire une ligne de fichier par ligne 
Python :: python convert docx to pdf 
Python :: how to get var value by name godot 
Python :: boto3 upload dataframe directly to s3 
Python :: .size pandas 
Python :: fonction nombre premier python 
Python :: dataFrame changed by function 
Python :: importing time and sleep. python 
ADD CONTENT
Topic
Content
Source link
Name
7+9 =