目录
1. 写一个简单(+-*/)的计算器, 确保输入的都是数字(如果不是数字,让它重新输入) 输入格式必须是: 7+8 => 输出格式是 7 + 8 = 15
编辑3. str字符串中的strip, replace, split, partition, expandtabs, join,center, ljust, rjust
1. 写一个简单(+-*/)的计算器, 确保输入的都是数字(如果不是数字,让它重新输入)
输入格式必须是: 7+8 => 输出格式是 7 + 8 =
![](https://i-blog.csdnimg.cn/blog_migrate/7dcb78823f859f91ec979b56d272ece4.png)
2. while单层循环完成9 * 9乘法表
![](https://i-blog.csdnimg.cn/blog_migrate/fcb012a4556d2caef053907ef0f3732b.png)
3. str字符串中的strip, replace, split, partition, expandtabs, join,center, ljust, rjust
- strip
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.
返回一个删除前导和尾随空格的字符串副本。
如果已给出字符而非无,则删除字符中的字符。
- replace
replace(self, old, new, count=-1, /)
Return a copy with all occurrences of substring old replaced by new.
返回一个包含所有出现的子字符串旧替换为新的副本。
- split
split(self, /, sep=None, maxsplit=-1)
Return a list of the words in the string, using sep as the delimiter string.
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.
maxsplit
Maximum number of splits to do.
-1 (the default value) means no limit.
拆分(Self,/,Sep=None,maxsplit=-1)
返回字符串中单词的列表,使用SEP作为分隔符字符串。
|||
C
要拆分字符串的分隔符。
无(默认值)指按任何空格拆分,
从结果中丢弃空字符串。
最大劈裂
最大数目的分裂要做。
1(默认值)表示无限制。
- partition
partition(self, sep, /)
Partition the string into three parts using the given separator.
使用给定的分隔符将字符串划分为三个部分。
- expandtabs
expandtabs(self, /, tabsize=8)
Return a copy where all tab characters are expanded using spaces.
返回一个所有制表符都使用空格展开的副本。
- join(self, iterable, /)
连接任意数量的字符串。被调用方法的字符串被插入到每个给定字符串之间。结果将作为一个新字符串返回。
- center(self, width, fillchar=' ', /)
返回一个长度宽度为中心的字符串。
填充使用指定的填充字符(默认为空格)。
- ljust(self, width, fillchar=' ', /)
- rjust(self, width, fillchar=' ', /)
4. 格式化输出:
姓名 年龄 性别 家庭住址
xxx xxxx
list_data = [{name: xxx, age: xxx, gender: xxx, address}, .....]
包含居中对齐,向左对齐, 向右对齐