In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-03 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
In this issue, the editor will bring you about how to treat the general replacement form of Python strings. The article is rich in content and analyzes and narrates it from a professional point of view. I hope you can get something after reading this article.
Alignment of Python strings on output:
S.ljust (width, [fillchar])
# output width characters, S left-aligned, the insufficient part is filled with fillchar, the default is space.
S.rjust (width, [fillchar]) #
Align right
S.center (width, [fillchar]) #
Middle alignment S.zfill (width) # changes S to width length and aligns it to the right, with zero to complement the search and replace in the string:
S.find (substr, [start, [end]])
# returns the label of the * letter of substr in S, or-1 if there is no substr in S. The role of start and end is equivalent to searching in S [start: end]
S.index (substr, [start, [end]])
# is the same as find (), except that if there is no substr in S, a runtime error will be returned
S.rfind (substr, [start, [end]])
# returns the * letter label of the substr that appears in S, and returns-1 if there is no substr in S, that is, the first letter label of the substr that appears for the * times from the right
S.rindex (substr, [start, [end]]) S.count (substr, [start, [end]]) #
Calculate the number of substr occurrences in S
S.replace (oldstr, newstr, [count])
# replace oldstar in S with newstr,count as the number of replacements. This is a general form of substitution, and there are some functions that replace special characters.
The above is the general form of replacement of Python strings shared by the editor. If you happen to have similar doubts, please refer to the above analysis to understand. If you want to know more about it, you are welcome to follow the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 222
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.