string - Get time that program ran (Python) -
im writing python script , im going make last updated: , time lst updated im not sure how
here , example code
from pil import imagedraw import ctypes, time import urllib import manipulate import datetime font_size = 50 font_color = "red" font = imagefont.load_default() img = image.open('bg.bmp') draw = imagedraw.draw(img) time = datetime.datetime.now() draw.text((650, 450),' current grades' ) draw.text((650, 500), 'period 1: geography -----------------------------') draw.text((650, 550), 'period 2: francais-------------------------------') draw.text((650, 600), 'period 3: science--------------------------------') draw.text((650, 650), 'period 4: p.e------------------------------------') draw.text((650, 700), 'period 5: algebra 9------------------------------') draw.text((650, 750), 'period 6: la-------------------------------------') draw.text((650, 800), 'last updated:'(time)) draw = imagedraw.draw(img) draw = imagedraw.draw(img) img.save('mod_bg.bmp') pathtobmp = "c:\python27\mod_bg.bmp" spi_setdeskwallpaper = 20 ctypes.windll.user32.systemparametersinfoa(spi_setdeskwallpaper, 0, pathtobmp , 0)
and last updated need time come after
when try error
traceback (most recent call last): file "c:\python27\project.py", line 28, in <module> draw.text((650, 800), 'last updated:'(time)) typeerror: 'str' object not callable
if can please do! thank you!
use datetime
import datetime = datetime.datetime.now() draw.text((650, 800), 'last updated: {0}'.format(now))
Comments
Post a Comment