zoukankan      html  css  js  c++  java
  • AttributeError: 'NoneType' object has no attribute 'span'

    1、错误描述

    E:PycharmProjectscmnvenvScriptspython.exe E:/PycharmProjects/cmn/venv/com.you.cmn/L.py
    Traceback (most recent call last):
      File "E:/PycharmProjects/cmn/venv/com.you.cmn/L.py", line 3, in <module>
        a = re.match("@","454545@qq.com").span();
    AttributeError: 'NoneType' object has no attribute 'span'
    
    Process finished with exit code 1

    2、错误原因

          在匹配@时,不是以这个开头,调用span()出现None.span(),出现报错

    import re;
    
    a = re.match("@","454545@qq.com").span();
    print(a);

    3、解决办法

    (1)如果后面匹配不是以前面的字符,不使用span()

    import re;
    
    a = re.match("@","454545@qq.com");
    print(a);

    (2)以某个字符开头,调用span()

    import re;
    
    a = re.match("@","@454545@qq.com").span();
    print(a);
  • 相关阅读:
    test14
    test13
    test12
    test11
    Xcode常用快捷键
    OC弱语法
    对象的结构体属性的成员修改
    IOS 获取手机各种信息
    IOS app启动过程
    iOS退出键盘的两种方式
  • 原文地址:https://www.cnblogs.com/hzcya1995/p/13313686.html
Copyright © 2011-2022 走看看