0
我試圖保存圖像,但我收到一條錯誤消息,說沒有這樣的文件或目錄,即使我保存了圖片。Python腳本圖像保存目錄/文件名錯誤
import PIL
from PIL import ImageFont
from PIL import Image
from PIL import ImageDraw
import ctypes, time
import urllib
while 1:
font_size = 50
font = ImageFont.load_default()
img = Image.open('bg.bmp')
draw = ImageDraw.Draw(img)
draw.text((300, 500), 'Period 1: ')
draw.text((300, 550), 'Period 2: ')
draw.text((300, 600), 'Period 3: ')
draw.text((300, 650), 'Period 4: ')
draw.text((300, 700), 'Period 5: ')
draw.text((300, 750), 'Period 6: ')
draw = ImageDraw.Draw(img)
draw = ImageDraw.Draw(img)
img.save("mod_bg.bmp")
pathToBmp = "C:\Documents and Settings\User\My Documents\My Pictures\ScreenShot.bmp"
SPI_SETDESKWALLPAPER = 20
ctypes.windll.user32.SystemParametersInfoA(SPI_SETDESKWALLPAPER, 0, pathToBmp , 0)
quit()
這是錯誤消息
Traceback (most recent call last):
File "C:\Documents and Settings\User\Desktop\Project.py", line 12, in <module>
img = Image.open('bg.bmp')
File "C:\Python27\lib\site-packages\PIL\Image.py", line 1952, in open
fp = __builtin__.open(fp, "rb")
IOError: [Errno 2] No such file or directory: 'bg.bmp'