你好,我有以下功能:def width(input,output,attr):
import re
input = input.strip()
if re.search(attr, input):
k = input.find(attr)
for i in input:
if i == attr[0]:
j = k + len(attr)+1
while ((j <= len(input)) | (j != ' ') | (input[j+1] != "'")):
j = j + 1
#print j, output, input[j], len(input), k
output = output+input[j]
break
k = k + 1
return output
print width('a=\'100px\'','','a')
我总是得到以下错误:Traceback (most recent call last):
File "table.py", line 45, in
print width(split_attributes(w,'','
'),'','width')File "table.py", line 24, in width
while ((j <= len(input)) | (j != ' ') | (input[j+1] != "'")):
IndexError: string index out of range
我试过用or代替|但没有成功!