Why Is My Python Code Returning Text:'my String' Instead Of Just My String?
my code snippet looks like this: for current_row in range(worksheet.nrows): fname_text = worksheet.row(current_row)[0] lname_text = worksheet.row(current_row)[1] cmt =
Solution 1:
That's what Cell
objects look like:
>>> sheet.row(0)
[text:u'RED', text:u'RED', empty:'']
>>> sheet.row(0)[0]
text:u'RED'>>> type(sheet.row(0)[0])
<class'xlrd.sheet.Cell'>
You can get at the wrapped values in a few ways:
>>> sheet.row(0)[0].value
u'RED'>>> sheet.row_values(0)
[u'RED', u'RED', '']
and remember you can access cells without going via row
:
>>> sheet.cell(0,0).value
u'RED'
Post a Comment for "Why Is My Python Code Returning Text:'my String' Instead Of Just My String?"