pythonfor循环中遍历的类型_python 学习之数据类型和for循环

论坛 期权论坛     
选择匿名的用户   2021-5-22 18:44   77   0
<p>classstr(object):&#34;&#34;&#34;str(object&#61;&#39;&#39;) -&gt; str</p>
<p>str(bytes_or_buffer[, encoding[, errors]]) -&gt; str</p>
<p>Create a new string object from the given object. If encoding or</p>
<p>errors is specified, then the object must expose a data buffer</p>
<p>that will be decoded using the given encoding and error handler.</p>
<p>Otherwise, returns the result of object.__str__() (if defined)</p>
<p>or repr(object).</p>
<p>encoding defaults to sys.getdefaultencoding().</p>
<p>errors defaults to &#39;strict&#39;.&#34;&#34;&#34;</p>
<p>def capitalize(self): #real signature unknown; restored from __doc__</p>
<p>&#34;&#34;&#34;#将 字符串首字母 小写改大写</p>
<p>S.capitalize() -&gt; str</p>
<p>Return a capitalized version of S, i.e. make the first character</p>
<p>have upper case and the rest lower case.&#34;&#34;&#34;</p>
<p>return &#34;&#34;</p>
<p>def casefold(self): #real signature unknown; restored from __doc__</p>
<p>&#34;&#34;&#34;S.casefold() -&gt; str</p>
<p>Return a version of S suitable for caseless comparisons.&#34;&#34;&#34;</p>
<p>return &#34;&#34;</p>
<p>def center(self, width, fillchar&#61;None): #real signature unknown; restored from __doc__</p>
<p>&#34;&#34;&#34;可以为字符串 填充自定字符 长度&#61;字符&#43;指定字符</p>
<p>S.center(width[, fillchar]) -&gt; str</p>
<p>Return S centered in a string of length width. Padding is</p>
<p>done using the specified fill character (default is a space)&#34;&#34;&#34;</p>
<p>return &#34;&#34;</p>
<p>def count(self, sub, start&#61;None, end&#61;None): #real signature unknown; restored from __doc__</p>
<p>&#34;&#34;&#34;下面是详细参数:</p>
<p>子串:是要搜索的子串。</p>
<p>开始:从该指数开始搜索。第一个字符从索引0开始。通过默认搜索引擎从索引0开始。</p>
<p>结束:搜索从该指数结束。第一个字符从索引0开始。默认情况下,搜索结束,在最后一个索引。</p>
<p>S.count(sub[, start[, end]]) -&gt; int</p>
<p>Return the number of non-overlapping occurrences of substring sub in</p>
<p>string S[start:end]. Optional arguments start and end are</p>
<p>interpreted as in slice notation.&#34;&#34;&#34;</p>
<p>return0def encode(self, encoding&#61;&#39;utf-8&#39;, errors&#61;&#39;strict&#39;): #real signature unknown; restored from __doc__</p>
<p>&#34;&#34;&#34;编码 上面有介绍</p>
<p>S.encode(encoding&#61;&#39;utf-8&#39;, errors&#61;&#39;strict&#39;) -&gt; bytes</p>
<p>Encode S using the codec registered for encoding. Default encoding</p>
<p>is &#39;utf-8&#39;. errors may be given to set a different error</p>
<p>handling scheme. Default is &#39;strict&#39; meaning that encoding errors raise</p>
<p>a UnicodeEncodeError. Other possible values are &#39;ignore&#39;, &#39;replace&#39; and</p>
<p>&#39;xmlcharrefreplace&#39; as well as any other name registered with</p>
<p>codecs.register_error that can handle UnicodeEncodeErrors.&#34;&#34;&#34;</p>
<p>return b&#34;&#34;</p>
<p>def endswith(self, suffix, start&#61;None, end&#61;None): #real signature unknown; restored from __doc__</p>
<p>&#34;&#34;&#34;以 某个字符结束</p>
<p>suffix -- 该参数可以是一个字符串或者是一个元素。</p>
<p>start -- 字符串中的开始位置。</p>
<p>end -- 字符中结束位置。</p>
<p>返回值</p>
<p>如果字符串含有指定的后缀返回True,否则返回False。</p>
<p>S.endswith(suffix[, start[, end]]) -&gt; bool</p>
<p>Return True if S ends with the specified suffix, False otherwise.</p>
<p>With optional start, test S beginning at that position.</p>
<p>With optional end, stop comparing S at that position.</p>
<p>suffix can also be a tuple of strings to try.&#34;&#34;&#34;</p>
<p>returnFalsedef expandtabs(self, tabsize&#61;8): #real signature unknown; restored from __doc__</p>
<p>&#34;&#34;&#34;把tab转换成空格</p>
<p>S.expandtabs(tabsize&#61;8) -&gt; str</p>
<p>Return a copy of S where all tab characters are expanded using spaces.</p>
<p>If tabsize is not given, a tab size of 8 characters is assumed.&#34;&#34;&#34;</p>
<p>return &#34;&#34;</p>
<p>def find(self, sub, start&#61;None, end&#61;None): #real signature unknown; restored from __doc__</p>
<p>&#34;&#34;&#34;find(str, pos_start, pos_end)</p>
<p>解释:</p>
<p>str:被查找“字串”</p>
<p>pos_start:查找的首字母位置(从0开始计数。默认:0)</p>
<p>pos_end: 查找的末尾位置(默认-1)</p>
<p>返回值:如果查到:返回查找的第一个出现的位置。否则,返回-1。</p>
<p>S.find(sub[, start[, end]]) -&gt; int</p>
<p>Return the lowest index in S where substring sub is found,</p>
<p>such that sub is contained within S[start:end]. Optional</p>
<p>arguments start and end are interpreted as in slice notation.</p>
<p>Return -1 on failure.&#34;&#34;&#34;</p>
<p>return0def format(*args, **kwargs): #known special case of str.format</p>
<p>&#34;&#34;&#34;占位符 类似变量引用</p>
<p>s &#61; &#34;print hell {0} ,age {1}&#34;</p>
<p>print(s.format(&#39;alex&#39;,19))</p>
<p>S.format(*args, **kwargs) -&gt; str</p>
<p>Return a formatted version of S, using substitutions from args and kwargs.</p>
<p>The substitutions are identified by braces (&#39;{&#39; and &#39;}&#39;).&#34;&#34;&#34;</p>
<p>pass</p>
<p>def format_map(self, mapping): #real signature unknown; restored from __doc__</p>
<p>&#34;&#34;&
分享到 :
0 人收藏
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

积分:3875789
帖子:775174
精华:0
期权论坛 期权论坛
发布
内容

下载期权论坛手机APP