Integers from excel files become floats?

后端 未结 5 675
忘了有多久
忘了有多久 2020-12-01 12:42

I use xlrd to read data from excel files.

For integers stored in the files, let\'s say 63, the xlrd interprets it as 63.

5条回答
  •  被撕碎了的回忆
    2020-12-01 13:18

    The answer given by jcollado is alright if you have all the entries in the excel sheet as numbers which are integers. But suppose you have a number which is a float you can always put a check condition like -

        if i==int(i): //checking for the integer:
          print int(i)      // solving your problem and printing the integer
        else:
          print i           //printing the float if present
    

    Hope you find this useful :)

提交回复
热议问题