0
我導入了一個文件background_image.txt
,其中包含字符串參考background_image
是一個base 64編碼圖形。當我編譯程序,我得到的錯誤日誌中的錯誤:解碼base 64編碼圖形時無法理解錯誤
Traceback (most recent call last):
File "main.py", line 23, in <module>
background_image = io.StringIO(base64.decode(background_image.background_image))
TypeError: decode() missing 1 required positional argument: 'output'
這是線#23
background_image = io.StringIO(base64.decode(background_image.background_image)) # line 23
這是減少verison我的計劃。這個程序使用tkinter創建一個窗口,使用base 64編碼圖形作爲畫布背景。
# modules
from tkinter import *
from PIL import ImageTk, Image
import io
import base64
# imported files
import background_image
# variables
background_image = io.StringIO(base64.decode(background_image.background_image)) # line 23
# window creation
root = Tk()
# canvas creation
canvas = Canvas(root, width=600, height=600, bd=-2)
canvas.pack()
# canvas attributes
background = ImageTk.PhotoImage(file=background_image)
canvas.create_image(0, 0, image=background, anchor=NW)
text = canvas.create_text(125, 75, anchor=CENTER)
# end
root.after(0, display)
root.mainloop()
這兩個參數都應該是文件。 – 2014-11-23 12:58:51