"不良角色范围"例外?

Fed*_*rer 2 django

错误:

Exception Value:     bad character range
Exception Location:  /usr/lib/python2.6/re.py in _compile, line 245
Python Executable:   /usr/bin/python
Run Code Online (Sandbox Code Playgroud)

我完全不知道这意味着什么.任何人都可以冒险猜测或指向正确的方向吗?

之前一切正常.我只改变了一些微不足道的代码!:S

if "-" in stop:
    dt1 = datetime.strptime(stop, "%Y-%m-%dT%H:%M:%S")
    stopInS = time.mktime(dt1.timetuple())
    stopInMS = int(startInS) * 1000
else:
    splitter = re.compile(r'[\D]')
    preStop = splitter.split(stop)
    stopInMS = ''.join(preStop)
Run Code Online (Sandbox Code Playgroud)

我只是在'in'之前玩弄双引号...然后整个事情因这个错误而崩溃了.

编辑:

另一个正则表达式:

    splitter1 = re.compile('[:]')
    arrayOfIDs = splitter1.split(identifier)
    idLens = len(arrayOfIDs)
Run Code Online (Sandbox Code Playgroud)

Dom*_*ger 7

你得到的例外是因为Python的re.py模块无法在某处编译正则表达式,因为你的字符范围很差.

字符范围是类似的[a-z0-9](接受小写字母或数字).

例如:

import re
re.compile('[a-0]')
Run Code Online (Sandbox Code Playgroud)

提出bad character range你得到的例外.寻找你正在创造一个没有意义的角色范围的某个地方(它不是[:],编译得很好).