Reputation: 6511
i want to know, the result format of xlrd.
See the code
>>> sh.cell_value(rowx=2, colx=1)
u'Adam Gilchrist xxxxxxxxxxxxxxxxxxxxx'
Now when i try running a res.search
>>> temp1=sh.cell_value(rowx=2, colx=1)
>>> x=re.search("Adam",'temp1')
>>> x.group()
Traceback (most recent call last):
File "<pyshell#58>", line 1, in <module>
x.group()
AttributeError: 'NoneType' object has no attribute 'group'
I get nothing.
sh.cell_value
. Is it integer, string etc.Upvotes: 0
Views: 508
Reputation: 7056
Your code passes "temp1" to re.search as a string. It does not pass the variable temp1. You want:
>>> x=re.search(u"Adam",temp1)
Upvotes: 1
Reputation: 63747
Answering your question first
u'Adam Gilchrist xxxxxxxxxxxxxxxxxxxxx'
means the test in unicode.temp1=u'Adam Gilchrist xxxxxxxxxxxxxxxxxxxxx' x=re.search(u'Adam',temp1) x.group() u'Adam'
Its only that you have to specify the pattern in unicode also.
Upvotes: 1