This is super simple with format
:
>>> a = "John"
>>> "{:<15}".format(a)
'John '
More Related Contents:
- How do I print curly-brace characters in a string while using .format?
- Format timedelta to string
- Python TypeError: not enough arguments for format string
- How do I escape curly-brace ({}) characters in a string while using .format (or an f-string)?
- Inserting the same value multiple times when formatting a string
- Why do I get “TypeError: not all arguments converted during string formatting” trying to check for an even/odd number?
- How to handle special cases in my Python code?
- Convert a String representation of a Dictionary to a dictionary?
- How to extract the substring between two markers?
- Remove unwanted parts from strings in a column
- What is the difference between a string and a byte string?
- Good Python modules for fuzzy string comparison? [closed]
- Python regex match OR operator
- Efficient way to add spaces between characters in a string
- Convert hex to binary
- How to extract an IP address from an HTML string?
- Regex for existence of some words whose order doesn’t matter
- How to test if one string is a subsequence of another? [duplicate]
- How would I get everything before a : in a string Python
- Why python’s list slicing doesn’t produce index out of bound error? [duplicate]
- How to remove symbols from a string with Python? [duplicate]
- Detecting Vowels vs Consonants In Python [duplicate]
- Python: format string with custom delimiters [duplicate]
- Why does Python not perform type conversion when concatenating strings?
- How to convert a string with comma-delimited items to a list in Python?
- How to read user input until EOF?
- How to determine whether a substring is in a different string [duplicate]
- String concatenation vs. string substitution in Python
- Column of lists, convert list to string as a new column
- Concatenate elements of a tuple in a list in python [duplicate]