• 技术文章 >Python技术 >Python基础教程

    python isidentifier()方法是什么

    小妮浅浅小妮浅浅2021-08-24 09:21:43原创3051

    说明

    1、用于判断字符串是否是有效的Python标识符,还可以用来判断变量名是否合法。

    2、如果字符串是有效的Python标识符返回True,否则返回False。

    实例

    判断字符串是否为Python标识符或者变量名是否合法。

    print('if'.isidentifier())  # True
    print('break'.isidentifier())  # True
    print('while'.isidentifier())  # True
    print('_b'.isidentifier())  # True
    print('重庆大学888m'.isidentifier())  # True
    print('886'.isidentifier())  # False
    print('8a'.isidentifier())  # False
    print(''.isidentifier())  # False

    以上就是python isidentifier()方法的介绍,希望对大家有所帮助。更多Python学习指路:python基础教程

    本文教程操作环境:windows7系统、Python 3.9.1,DELL G3电脑。

    专题推荐:python isidentifier
    品易云
    上一篇:python isdigit如何判断字符串 下一篇:python中isnumeric如何使用

    相关文章推荐

    • python从键盘输入若干个整数• python中slice的三个参数• python列表有几种切片形式• python决策树算法是什么• python决策树算法的实现步骤• python如何判断文件夹内的重复图片• python一行输出10个数• Python输入三个数用空格隔开• python计算在月球的体重• python两种不同的文件流读写• python如何在二维图像上进行卷积• python读取txt文件• python中mock的断言使用• python中mock有哪些统计的方法• python异常是什么?如何解决?• python归并排序的基本思路• python快速排序的运作过程• python归并排序和快速排序比较• python Tkinter模块是什么• python美元转换成人民币转换代码• python命名关键字参数的使用注意• python如何防止栈溢出• python输入身高体重算BMI• python基本颜色代码• python99乘法表代码• 判断水仙花数python代码

    全部评论我要评论

    © 2021 Python学习网 苏ICP备2021003149号-1

  • 取消发布评论
  • 

    Python学习网