You can prefix the size requirement with -
to left-justify:
sys.stdout.write("%-6s %-50s %-25s\n" % (code, name, industry))
More Related Contents:
- How to use % symbol correctly
- How do I print curly-brace characters in a string while using .format?
- How can I fill out a Python string with spaces?
- Python’s many ways of string formatting — are the older ones (going to be) deprecated?
- How can I format a decimal to always show 2 decimal places?
- Display a decimal in scientific notation
- How do I turn a python datetime into a string, with readable format date?
- Format output string, right alignment
- f-strings vs str.format()
- Format a datetime into a string with milliseconds
- What’s the difference between %s and %d in Python string formatting?
- How can I convert 24 hour time to 12 hour time?
- Format strings vs concatenation
- Logging variable data with new format string
- Format numbers to strings in Python
- How to get Python to gracefully format None and non-existing fields [duplicate]
- How can I extract keywords from a Python format string?
- Print floating point values without leading zero
- How to implement conditional string formatting?
- How do I escape curly-brace ({}) characters in a string while using .format (or an f-string)?
- Most Pythonic way to print *at most* some number of decimal places [duplicate]
- How can I use f-string with a variable, not with a string literal?
- Can Python’s logging format be modified depending on the message log level?
- How do I format a number with a variable number of digits in Python?
- How to convert escaped characters? [duplicate]
- str.format() raises KeyError
- Python, print all floats to 2 decimal places in output
- advanced string formatting vs template strings
- Leaving values blank if not passed in str.format
- python format string thousand separator with spaces