字符串
-
Python 常用字符串处理方法
> Python 字符串处理 1. 使用字符串方法 translate() 替换字符串中的字符 translate() 方法可以根据指定的映射表替换字符串中的字符。 translation_table = str.maketrans("aeiou", "12345") s = "hello world" new_s = s.translate(translation_table) print(new_s) # 输出: h2ll4 w4rld 2. 使用 …