栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Python

python第五次作业

Python 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

python第五次作业

1.写一个简单的(+-*/)的计算器,确保输入的都是数字(如果不是数字,让他重新输入)

可以得到结果

2.while单层循环完成9*9乘法表

递归

计算所有i(1-9)与j(1-9)的乘法再加条件限制显示

改进后,不必计算重复的值

3.str字符串中的部分方法

|  center(self, width, fillchar=' ', /)
|      Return a centered string of length width.
|      返回一个长宽居中的字符串
|      Padding is done using the specified fill character (default is a space).
|   填充是使用指定的填充字符完成的(默认为空格)

 |  expandtabs(self, /, tabsize=8)
 |      Return a copy where all tab characters are expanded using spaces.
 |      返回使用空格展开所有制表符的副本。
 |      If tabsize is not given, a tab size of 8 characters is assumed.
 |      如果未给定tabsize,则假定tab大小为8个字符。

 |  join(self, iterable, /)
 |      Concatenate any number of strings.
 |      串联任意数量的字符串。
 |      The string whose method is called is inserted in between each given string.
 |      The result is returned as a new string.
 |      调用其方法的字符串插入到每个给定字符串之间。
 |      结果将作为新字符串返回。

 |  ljust(self, width, fillchar=' ', /)
 |      Return a left-justified string of length width.
 |      返回长度宽度为左对齐的字符串。

 |  rjust(self, width, fillchar=' ', /)
 |      Return a right-justified string of length width.
 |      返回长度宽度为右对齐的字符串。
 |      Padding is done using the specified fill character (default is a space).
 |      填充是使用指定的填充字符完成的(默认为空格)

 |  partition(self, sep, /)
 |      Partition the string into three parts using the given separator.
 |      使用给定的分隔符将字符串分为三部分。
 |      This will search for the separator in the string.  If the separator is found,
 |      returns a 3-tuple containing the part before the separator, the separator
 |      itself, and the part after it.
 |      
 |      If the separator is not found, returns a 3-tuple containing the original string
 |      and two empty strings.
 |      如果未找到分隔符,则返回包含原始字符串的3元组和两个空字符串。

 |  replace(self, old, new, count=-1, /)
 |      Return a copy with all occurrences of substring old replaced by new.
 |      返回一个副本,其中所有出现的子字符串旧替换为新。
 |        count
 |          Maximum number of occurrences to replace.
 |          -1 (the default value) means replace all occurrences.
 |          要替换的最大出现次数。
 |    -1(默认值)表示替换所有引用。
 |      If the optional argument count is given, only the first count occurrences are
 |      replaced.
 |      如果给定了可选的参数计数,则只会出现第一次计数已替换。

 |  split(self, /, sep=None, maxsplit=-1)
 |      Return a list of the words in the string, using sep as the delimiter string.
 |      使用sep作为分隔符字符串,返回字符串中的单词列表。
 |      sep
 |        The delimiter according which to split the string.
 |        None (the default value) means split according to any whitespace,
 |        and discard empty strings from the result.
 |    分割字符串所依据的分隔符。
 |    None(默认值)表示根据任何空格进行拆分,
 |    并从结果中丢弃空字符串。
 |      maxsplit
 |        Maximum number of splits to do.
 |        -1 (the default value) means no limit.

 |  strip(self, chars=None, /)
 |      Return a copy of the string with leading and trailing whitespace removed.
 |      返回删除前导和尾随空格的字符串副本。
 |      If chars is given and not None, remove characters in chars instead.
 |      如果给定了chars而不是None,请删除chars中的字符。

4.格式化输出

 格式化输出三种方式

"str".format()

"str".format_map()

f/F"str"

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/990776.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号