
# 概述
本文介绍字符串函数的语法规则，包括参数解释、函数示例等。
#### 函数列表
| 类型       | 函数                                                                                                                                                                                                            | 说明                              |
|:---|:---|:---|
| 多字符串操作   | [str_format](https://support.huaweicloud.com/usermanual-lts/lts_07_0167.html#lts_07_0167__zh-cn_topic_0000002058179326_zh-cn_topic_0000001891594188_zh-cn_topic_0000001628886600_section28841019104615)       | 按照指定格式对字符串进行格式化。                |
| 多字符串操作   | [str_join](https://support.huaweicloud.com/usermanual-lts/lts_07_0167.html#lts_07_0167__zh-cn_topic_0000002058179326_zh-cn_topic_0000001891594188_zh-cn_topic_0000001628886600_section1572162520462)          | 通过连接符将输入的字符串连接生成一个新的字符串。        |
| 多字符串操作   | [str_zip](https://support.huaweicloud.com/usermanual-lts/lts_07_0167.html#lts_07_0167__zh-cn_topic_0000002058179326_zh-cn_topic_0000001891594188_zh-cn_topic_0000001628886600_section894993434614)            | 将两个值或表达式的字符串进行并发分裂然后再合并成一个字符串。  |
| 排序、反转、替换 | [str_sort](https://support.huaweicloud.com/usermanual-lts/lts_07_0167.html#lts_07_0167__zh-cn_topic_0000002058179326_zh-cn_topic_0000001891594188_zh-cn_topic_0000001628886600_section695015439469)           | 字符串排序。                          |
| 排序、反转、替换 | [str_reverse](https://support.huaweicloud.com/usermanual-lts/lts_07_0167.html#lts_07_0167__zh-cn_topic_0000002058179326_zh-cn_topic_0000001891594188_zh-cn_topic_0000001628886600_section137241452194616)     | 将一个字符串进行反转。                     |
| 排序、反转、替换 | [str_replace](https://support.huaweicloud.com/usermanual-lts/lts_07_0167.html#lts_07_0167__zh-cn_topic_0000002058179326_zh-cn_topic_0000001891594188_zh-cn_topic_0000001628886600_section447017234719)        | 根据规则将旧字符串替换成新字符串。               |
| 排序、反转、替换 | [str_translate](https://support.huaweicloud.com/usermanual-lts/lts_07_0167.html#lts_07_0167__zh-cn_topic_0000002058179326_zh-cn_topic_0000001891594188_zh-cn_topic_0000001628886600_section54560104472)       | 将字符串中的指定字符按照对应关系进行替换。           |
| 常见操作     | [str_strip](https://support.huaweicloud.com/usermanual-lts/lts_07_0168.html#lts_07_0168__zh-cn_topic_0000002094178181_zh-cn_topic_0000001891754100_zh-cn_topic_0000001677566381_section185451311818)          | 删除字符串中指定的字符。                    |
| 常见操作     | [str_lstrip](https://support.huaweicloud.com/usermanual-lts/lts_07_0168.html#lts_07_0168__zh-cn_topic_0000002094178181_zh-cn_topic_0000001891754100_zh-cn_topic_0000001677566381_section111723951814)         | 删除字符串开头的指定字符。                   |
| 常见操作     | [str_rstrip](https://support.huaweicloud.com/usermanual-lts/lts_07_0168.html#lts_07_0168__zh-cn_topic_0000002094178181_zh-cn_topic_0000001891754100_zh-cn_topic_0000001677566381_section17209819161810)       | 删除字符串结尾的指定字符。                   |
| 常见操作     | [str_lower](https://support.huaweicloud.com/usermanual-lts/lts_07_0168.html#lts_07_0168__zh-cn_topic_0000002094178181_zh-cn_topic_0000001891754100_zh-cn_topic_0000001677566381_section64701826151814)        | 将字符串中所有大写字符转换为小写字符。             |
| 常见操作     | [str_upper](https://support.huaweicloud.com/usermanual-lts/lts_07_0168.html#lts_07_0168__zh-cn_topic_0000002094178181_zh-cn_topic_0000001891754100_zh-cn_topic_0000001677566381_section134131733151811)       | 将字符串中所有小写字符转换为大写字符。             |
| 常见操作     | [str_title](https://support.huaweicloud.com/usermanual-lts/lts_07_0168.html#lts_07_0168__zh-cn_topic_0000002094178181_zh-cn_topic_0000001891754100_zh-cn_topic_0000001677566381_section2619341191813)         | 将所有单词的第一个字母转化为大写，其余字母均为小写。      |
| 常见操作     | [str_capitalize](https://support.huaweicloud.com/usermanual-lts/lts_07_0168.html#lts_07_0168__zh-cn_topic_0000002094178181_zh-cn_topic_0000001891754100_zh-cn_topic_0000001677566381_section15240134961814)   | 将字符串的第一个字母转化为大写，其他字母转化为小写。      |
| 常见操作     | [str_swapcase](https://support.huaweicloud.com/usermanual-lts/lts_07_0168.html#lts_07_0168__zh-cn_topic_0000002094178181_zh-cn_topic_0000001891754100_zh-cn_topic_0000001677566381_section374515771812)       | 对字符串的大小写字母进行转换。                 |
| 查找判断     | [str_count](https://support.huaweicloud.com/usermanual-lts/lts_07_0169.html#lts_07_0169__zh-cn_topic_0000002058020998_zh-cn_topic_0000001934833833_zh-cn_topic_0000001628726672_section112171323191917)       | 统计字符串里某个字符出现的次数。                |
| 查找判断     | [str_find](https://support.huaweicloud.com/usermanual-lts/lts_07_0169.html#lts_07_0169__zh-cn_topic_0000002058020998_zh-cn_topic_0000001934833833_zh-cn_topic_0000001628726672_section0934162671917)          | 判断原字符串中是否包含指定的子字符串。             |
| 查找判断     | [str_rfind](https://support.huaweicloud.com/usermanual-lts/lts_07_0169.html#lts_07_0169__zh-cn_topic_0000002058020998_zh-cn_topic_0000001934833833_zh-cn_topic_0000001628726672_section53371735111917)        | 查找字符串中指定字符或者字符串最后一次出现的位置。       |
| 查找判断     | [str_endswith](https://support.huaweicloud.com/usermanual-lts/lts_07_0169.html#lts_07_0169__zh-cn_topic_0000002058020998_zh-cn_topic_0000001934833833_zh-cn_topic_0000001628726672_section1885574331910)      | 判断字符串是否以指定后缀结尾。                 |
| 查找判断     | [str_startswith](https://support.huaweicloud.com/usermanual-lts/lts_07_0169.html#lts_07_0169__zh-cn_topic_0000002058020998_zh-cn_topic_0000001934833833_zh-cn_topic_0000001628726672_section5414953121920)    | 判断字符串是否以指定字符串开头。                |
| 切分       | [str_split](https://support.huaweicloud.com/usermanual-lts/lts_07_0169.html#lts_07_0169__zh-cn_topic_0000002058020998_zh-cn_topic_0000001934833833_zh-cn_topic_0000001628726672_section114621242012)          | 通过指定分隔符对字符串进行分割。                |
| 切分       | [str_splitlines](https://support.huaweicloud.com/usermanual-lts/lts_07_0169.html#lts_07_0169__zh-cn_topic_0000002058020998_zh-cn_topic_0000001934833833_zh-cn_topic_0000001628726672_section34431312162010)   | 通过换行符对字符串进行分割。                  |
| 切分       | [str_partition](https://support.huaweicloud.com/usermanual-lts/lts_07_0169.html#lts_07_0169__zh-cn_topic_0000002058020998_zh-cn_topic_0000001934833833_zh-cn_topic_0000001628726672_section1073212223204)     | 根据指定的分隔符将字符串从左往右分割为三部分。         |
| 切分       | [str_rpartition](https://support.huaweicloud.com/usermanual-lts/lts_07_0169.html#lts_07_0169__zh-cn_topic_0000002058020998_zh-cn_topic_0000001934833833_zh-cn_topic_0000001628726672_section101051534112018)  | 根据指定的分隔符将字符串从右往左分割为三部分。         |
| 格式化      | [str_center](https://support.huaweicloud.com/usermanual-lts/lts_07_0169.html#lts_07_0169__zh-cn_topic_0000002058020998_zh-cn_topic_0000001934833833_zh-cn_topic_0000001628726672_section3735185122019)        | 用指定字符将字符串填充到指定长度。               |
| 格式化      | [str_ljust](https://support.huaweicloud.com/usermanual-lts/lts_07_0169.html#lts_07_0169__zh-cn_topic_0000002058020998_zh-cn_topic_0000001934833833_zh-cn_topic_0000001628726672_section20760754142015)        | 用指定字符将字符串从结尾填充至指定长度。            |
| 格式化      | [str_rjust](https://support.huaweicloud.com/usermanual-lts/lts_07_0169.html#lts_07_0169__zh-cn_topic_0000002058020998_zh-cn_topic_0000001934833833_zh-cn_topic_0000001628726672_section0770153112119)         | 用指定字符将原字符串从开头填充至指定长度。           |
| 格式化      | [str_zfill](https://support.huaweicloud.com/usermanual-lts/lts_07_0169.html#lts_07_0169__zh-cn_topic_0000002058020998_zh-cn_topic_0000001934833833_zh-cn_topic_0000001628726672_section1790013114210)         | 用字符0从开头将字符串填充至指定长度。             |
| 格式化      | [str_expandtabs](https://support.huaweicloud.com/usermanual-lts/lts_07_0169.html#lts_07_0169__zh-cn_topic_0000002058020998_zh-cn_topic_0000001934833833_zh-cn_topic_0000001628726672_section59161525182113)   | 将字符串中的\\t转为空格。                  |
| 字符集判断    | [str_isalnum](https://support.huaweicloud.com/usermanual-lts/lts_07_0170.html#lts_07_0170__zh-cn_topic_0000002094059617_zh-cn_topic_0000001891594192_zh-cn_topic_0000001629046548_section14539162322115)      | 判断字符串是仅由字母和数字组成。                |
| 字符集判断    | [str_isalpha](https://support.huaweicloud.com/usermanual-lts/lts_07_0170.html#lts_07_0170__zh-cn_topic_0000002094059617_zh-cn_topic_0000001891594192_zh-cn_topic_0000001629046548_section196417294218)        | 判断字符串是否仅由字母组成。                  |
| 字符集判断    | [str_isascii](https://support.huaweicloud.com/usermanual-lts/lts_07_0170.html#lts_07_0170__zh-cn_topic_0000002094059617_zh-cn_topic_0000001891594192_zh-cn_topic_0000001629046548_section1675464092114)       | 判断字符串由ASCII组成。                  |
| 字符集判断    | [str_isdecimal](https://support.huaweicloud.com/usermanual-lts/lts_07_0170.html#lts_07_0170__zh-cn_topic_0000002094059617_zh-cn_topic_0000001891594192_zh-cn_topic_0000001629046548_section53761849172117)    | 判断字符串是否仅包含十进制字符。                |
| 字符集判断    | [str_isdigit](https://support.huaweicloud.com/usermanual-lts/lts_07_0170.html#lts_07_0170__zh-cn_topic_0000002094059617_zh-cn_topic_0000001891594192_zh-cn_topic_0000001629046548_section428595882120)        | 判断字符串是否仅由数字组成。                  |
| 字符集判断    | [str_isidentifier](https://support.huaweicloud.com/usermanual-lts/lts_07_0170.html#lts_07_0170__zh-cn_topic_0000002094059617_zh-cn_topic_0000001891594192_zh-cn_topic_0000001629046548_section68311719220)    | 判断字符串是否是有效的Python标识符            |
| 字符集判断    | [str_islower](https://support.huaweicloud.com/usermanual-lts/lts_07_0170.html#lts_07_0170__zh-cn_topic_0000002094059617_zh-cn_topic_0000001891594192_zh-cn_topic_0000001629046548_section19117417132220)      | 判断字符串是否由小写字母组成。                 |
| 字符集判断    | [str_isnumeric](https://support.huaweicloud.com/usermanual-lts/lts_07_0170.html#lts_07_0170__zh-cn_topic_0000002094059617_zh-cn_topic_0000001891594192_zh-cn_topic_0000001629046548_section1218962717228)     | 判断字符串是否由数字组成。                   |
| 字符集判断    | [str_isprintable](https://support.huaweicloud.com/usermanual-lts/lts_07_0170.html#lts_07_0170__zh-cn_topic_0000002094059617_zh-cn_topic_0000001891594192_zh-cn_topic_0000001629046548_section136261846112217) | 判断字符串中是否所有字符都是可打印字符。            |
| 字符集判断    | [str_isspace](https://support.huaweicloud.com/usermanual-lts/lts_07_0170.html#lts_07_0170__zh-cn_topic_0000002094059617_zh-cn_topic_0000001891594192_zh-cn_topic_0000001629046548_section889865213226)        | 判断字符串是否仅由空格字符组成。                |
| 字符集判断    | [str_istitle](https://support.huaweicloud.com/usermanual-lts/lts_07_0170.html#lts_07_0170__zh-cn_topic_0000002094059617_zh-cn_topic_0000001891594192_zh-cn_topic_0000001629046548_section728211122318)        | 判断字符串中所有单词的拼写首字母是否为大写，且其他字母为小写。 |
| 字符集判断    | [str_isupper](https://support.huaweicloud.com/usermanual-lts/lts_07_0170.html#lts_07_0170__zh-cn_topic_0000002094059617_zh-cn_topic_0000001891594192_zh-cn_topic_0000001629046548_section12689189192310)      | 判断字符串中所有的字母是否都为大写。              |
| 字符集判断    | [str_uuid](https://support.huaweicloud.com/usermanual-lts/lts_07_0170.html#lts_07_0170__zh-cn_topic_0000002094059617_zh-cn_topic_0000001891594192_zh-cn_topic_0000001629046548_section1731027133917)          | 随机生成UUID。                       |
   
