1

I want to extract telephone number from *.xls with module xlrd using Python, but it shows like this:'16753435903.0'.

Here's the code:

opensheet = openxls.sheet_by_name(u'sms')
sheetrows = opensheet.nrows
for rownum in range(1, sheetrows):
    rowvalue = opensheet.row(rownum)
    execinfo = ""
    for colnum in range(1,5):
        execinfo += "'"+str(rowvalue[colnum].value)+"',"

The key part:

str(rowvalue[colnum].value)

How can I get the well format telephone number without .0?

Tangoo
  • 1,329
  • 4
  • 14
  • 34

1 Answers1

1

This might be a very simple workaround: convert the number to an int before converting it to a string?

Ian
  • 1,688
  • 18
  • 35