小编jav*_*ner的帖子

如何在java中使indexof case不敏感

我有一个简单的问题.如何在java中使indexof case不敏感.这个问题已经在一些论坛得到了回答,但我不明白答案.

比如说.我有一个字符串s = Phone(Conf)我想拉这样的记录(Conf),但是用户正在输入CONF或conf或Conf等.所以我的程序应该能够拉出记录在任何情况下它都会找到conf这个词.

    if(s.indexOf("(")>-1&& s.indexOf("Conf")>-4 && s.lastIndexOf(")")>-1)
 {
    String s1=s.substring(s.indexOf("(Conf"),s.lastIndexOf(")")+1);
   }
Run Code Online (Sandbox Code Playgroud)

有人可以解释一下吗?如果字符串仅为(Conf),则上面的代码将其拉出.

java indexof

7
推荐指数
1
解决办法
1万
查看次数

Python 错误 - TypeError: 不支持 + 的操作数类型:'NoneType' 和 'str'

我正在尝试调试现有脚本,但在运行脚本时出现以下错误。./check_tandbergvideo CE s 10.50.174.138 此脚本尝试检查端点是否已注册或未注册并返回状态。

回溯(最近一次调用):文件“./check_tandbergvideo”,第 156 行,在 main() 文件“./check_tandbergvideo”,第 114 行,在主 EP = getXML(sys.argv[3],sys.argv[1] ]) 文件“./check_tandbergvideo”,第 79 行,在 getXML H323Status = getElement(tree,xml2+"H323/"+xml2+"Gatekeeper/"+xml2+"Status") + "。错误:" + getElement(tree,xml2+" H323/"+xml2+"Gatekeeper/"+xml2+"Reason")
TypeError: 不支持的操作数类型 +: 'NoneType' 和 'str'

这是引发错误的代码部分。

if model == "CE":
  # SIPStatus =  getElement(tree,xml2+"SIP/"+xml2+"Registration/"+xml2+"Status") + ". Errors: " + getElement(tree,xml2+"SIP/"+xml2+"Registration/"+xml2+"Reason")
    SIPStatus =  str(getElement(tree,xml2+"SIP/"+xml2+"Profile/"+xml2+"Registration/"+xml2+"Status")) + ". Errors: " + str(getElement(tree,xml2+"SIP/"+xml2+"Profile/"+xml2+"Registration/"+xml2+"Reason"))
    H323Status = getElement(tree,xml2+"H323/"+xml2+"Gatekeeper/"+xml2+"Status") + ". Errors: " + getElement(tree,xml2+"H323/"+xml2+"Gatekeeper/"+xml2+"Reason")
    ReleaseKey =   getElement(tree,xml2+"SystemUnit/"+xml2+"Software/"+xml2+"ReleaseKey")
    EPModel = getElement(tree,xml2+"SystemUnit/"+xml2+"ProductId")
SWVer =getElement(tree,xml2+"SystemUnit/"+xml2+"Software/"+xml2+"Version")
    else:
    badSyntax()
EPData = …
Run Code Online (Sandbox Code Playgroud)

python

0
推荐指数
1
解决办法
2万
查看次数

标签 统计

indexof ×1

java ×1

python ×1