Python String expandtabs() Method
Python expandstabs() method replaces all the characters by sepecified spaces. By default a single tab expands to 8 spaces which can be overridden according to the requirement.
We can pass 1, 2, 4 and more to the method which will replace tab by the these number of space characters.
tabsize : It is optional and default value is 8.
It returns a modified string.
Let's see some examples to understand the expandtabs() method.
Python String expandtabs() Method Example 1
Calling method without specifying spaces. It sets to it's default value.
Welcome to the Javatpoint.
Python String expandtabs() Method Example 2
See, how the output is changing after each call. Each method is set to different-different number of spaces.
Welcome to the Javatpoint. Welcome to the Javatpoint. Welcome to the Javatpoint.
JavaTpoint offers too many high quality services. Mail us on [email protected], to get more information about given services.
JavaTpoint offers college campus training on Core Java, Advance Java, .Net, Android, Hadoop, PHP, Web Technology and Python. Please mail your requirement at [email protected]
Duration: 1 week to 2 week