0

I'm extracting one number from an XLS file :

var = workBook.sheet_by_index(3).cell_value(4,1) var = 0136 type(var) = float 

when I'm trying to print the var i got always different results :

print(int(var)) = 136 print(str(var)) = 136.0 

I don’t find a simple way to simply print out : 0136

2
  • I would suggest print it as a string. Commented Jul 26, 2016 at 8:50
  • What library are you using? Commented Jul 26, 2016 at 8:50

1 Answer 1

1

Try formatting

print('{:04d}'.format(136)) # Returns 0136 

In your case:

var = 136 print('{:04d}'.format(var)) # Returns: 0136 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.