zoukankan      html  css  js  c++  java
  • Python3中isdigit(), isdecimal(), isnumeric()的区别和字符串的常用方法

    # 全部小写
    string.lower()
    # 全部大写
    string.upper()
    # 是否全部小写
    string.islower()
    # 是否全部大写
    string.isupper()
    # 首字母大写
    string.capitalize()
    # 大小写转换
    string.swapcase()
    # 检查字符串是否是以 str 开头
    string.startswith(str)
    # 检查字符串是否是以 str 结束
    string.endswith(str)
    # 判断是不是纯阿拉伯数字
    string.isdigit()
    # 判断是不是字母和数字
    string.isalnum()
    # 判断是不是纯字母和汉字
    string.isalpha()
    # 返回列表,以 str 为分隔符拆分 string
    string.split(str="")
    # 返回字符串,以 string 作为分隔符
    string.join(可迭代对象)
    # 替换字符串
    string.replace(old_str, new_str)
    
    """
    isdigit(), isdecimal(), isnumeric()的区别
    
    isdigit()
    True: Unicode数字,byte数字(单字节),全角数字(双字节)
    False: 汉字数字,罗马数字,小数
    Error: 无 
    
    isdecimal() 
    True: Unicode数字,全角数字(双字节) 
    False: 罗马数字,汉字数字,小数
    Error: byte数字(单字节) 
    
    isnumeric() 
    True: Unicode数字,全角数字(双字节),罗马数字,汉字数字 
    False: 小数 
    Error: byte数字(单字节)
    """
    
  • 相关阅读:
    python协程爬取某网站的老赖数据
    python异步回调顺序?是否加锁?
    go语言循环变量
    使用memory_profiler异常
    安装python性能检测工具line_profiler
    等我!
    pytorch代码跟着写
    Python异常类型总结
    Python项目代码阅读【不断更新】
    夏令营体会
  • 原文地址:https://www.cnblogs.com/hellomrr/p/10710285.html
Copyright © 2011-2022 走看看