- 用法:- str.isidentifier()
- 如果字符串是根据语言定义、部分标识符和关键字的有效标识符,则返回 - True。- 调用 - keyword.iskeyword()测试字符串- s是否为保留标识符,例如- def和- class。- 例子: - >>> from keyword import iskeyword >>> 'hello'.isidentifier(), iskeyword('hello') (True, False) >>> 'def'.isidentifier(), iskeyword('def') (True, True)
相关用法
- Python str.isupper用法及代码示例
- Python str.expandtabs用法及代码示例
- Python str.title用法及代码示例
- Python str.rstrip用法及代码示例
- Python str.splitlines用法及代码示例
- Python str.lstrip用法及代码示例
- Python str.removeprefix用法及代码示例
- Python str.split用法及代码示例
- Python str.zfill用法及代码示例
- Python str.strip用法及代码示例
- Python str.format_map用法及代码示例
- Python str.removesuffix用法及代码示例
- Python str() vs repr()用法及代码示例
- Python string转integer用法及代码示例
- Python string strip()用法及代码示例
- Python string.octdigits用法及代码示例
- Python string.whitespace用法及代码示例
- Python strip()用法及代码示例
- Python str()用法及代码示例
- Python string capitalize()用法及代码示例
注:本文由纯净天空筛选整理自python.org大神的英文原创作品 str.isidentifier。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。
