30-输入题:title 首字母大写

30-输入题:title 首字母大写

语法讲解 今天学: title 的用法 s = input() print(s.title()) 小练习 输入为:hello world。运行下面代码后输出是什么? s = input() p

阅读更多 →
29-输入题:strip 后统计长度

29-输入题:strip 后统计长度

语法讲解 今天学: 输入字符串处理:strip + len s = input() s = s.strip() print(len(s)) 小练习 输入为:␠␠hello␠␠(两端各两个空格)

阅读更多 →
28-字符串拼接:join 还是 +(概念题)

28-字符串拼接:join 还是 +(概念题)

语法讲解 今天学: 字符串拼接的性能常识 # 概念示例(不要求运行) parts = ["a"] * 10000 s = "".join(parts)

阅读更多 →
27-难度5:translate 同时替换与删除

27-难度5:translate 同时替换与删除

语法讲解 今天学: translate:替换 + 删除 s = "Hello World" table = str.maketrans(" ", "_

阅读更多 →
26-难度5:split 产生空串,过滤再 join

26-难度5:split 产生空串,过滤再 join

语法讲解 今天学: split 后过滤空字符串再 join s = "a,,b,,,c," parts = [x for x in s.split(",") i

阅读更多 →
25-难度5:format 字段下标访问

25-难度5:format 字段下标访问

语法讲解 今天学: format 的字段访问能力(下标访问) user = {"name": "Bob"} nums = [42, 99] print(&quo

阅读更多 →
24-难度5:format_map + __missing__

24-难度5:format_map + __missing__

语法讲解 今天学: format_map 与 __missing__ class D(dict): def __missing__(self, key): return &qu

阅读更多 →
23-字符串比较:按 Unicode 字典序

23-字符串比较:按 Unicode 字典序

语法讲解 今天学: 字符串的字典序比较 print("Z" < "a") print("ab" < "aB"

阅读更多 →
22-count:不计算重叠匹配

22-count:不计算重叠匹配

语法讲解 今天学: count 的非重叠匹配 s = "aaaa" print(s.count("aa")) 小练习 运行下面代码后输出是什么? s =

阅读更多 →
21-removeprefix/removesuffix:匹配才移除

21-removeprefix/removesuffix:匹配才移除

语法讲解 今天学: removeprefix / removesuffix s = "https://example.com" print(s.removeprefix("

阅读更多 →