0

I want to pass integer value instead of String, say a = 45, but it's not working!

import Image
import ImageDraw
import ImageFont


width = disp.width
height = disp.height
image = Image.new('1', (width, height))

font = ImageFont.load_default()
a = 45

draw.text((x, top), a ,  font=font, fill=255)
draw.text((x, top+20), 'World!', font=font, fill=255)
0

1 Answer 1

1

Cast a to a string using draw.text((x, top), str(a) , font=font, fill=255).

You could also use a = '45' defining it as a string. However I would advise against this as you may want to use it as an integer before drawing it.

Sign up to request clarification or add additional context in comments.

3 Comments

but I am getting real-time data in this variable, so I can't make it string
Using str(a) will take the real time value of a and return a str representation of it, it will not affect the value of the variable a so should work with real time data.
Thanks! working fine :)

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.