What are the functions that python fills with compression
This article mainly shows you "what are the functions of python filling compression", the content is easy to understand, clear, hope to help you solve your doubts, the following let Xiaobian lead you to study and learn "what are the functions of python filling compression" this article.
1. Ljust and rjust strings start from the left / right, and are filled in after / before if it is not enough.
# a.ljust (), a.rjust # string starts from left / right It is not enough to fill the back / front with s = 'girl's_new = s.ljust (30djimi') # the length of the padding character is 1s_new1 = s.rjust (30meme') print (s_new) print (s_new1) output: girl---girl
2. Fill in both sides of the center string according to the specified length.
# a.center () # string is filled with s = 'girl's_new = s.center (50 s.center) print (s_new) output:-girl
3. Remove the space on the left side of ltrip,\ n, tab key, etc.
# a.ltrip () # left space,\ n, tab, etc. Remove s ='\ ngood day\ n\ thello's_new = s.lstrip () print (s_new) output: good day hello
4. Remove the space on the right side of rtrip,\ n, tab key, etc.
# a.rtrip () # the right space,\ n, tab key, etc., remove s = 'good day\ n\ t's_new = s.rstrip () print (s_new) output: good day above is all the contents of the article "what are the functions python fills and compresses?" Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!