_tkinter.TclError: expected floating-point number but got “floating“的解决办法

Traceback (most recent call last):
  File "D:\Users\Administrator\AppData\Local\Programs\Python\Python37-32\lib\tkinter\__init__.py", line 2467, in <listcomp>
    return [self.tk.getdouble(x) for x in
_tkinter.TclError: expected floating-point number but got "floating"

根据自己的经验,这种错误一般是绘制到画板Canvas上的图形溢出引发的。比如这个例子:

from tkinter import *
from math import nan
root=Tk()
c=Canvas()
c.pack()
c["bg"]="white"
c.create_line((nan,nan),(0,0),(inf.inf),(12,10)) # 值nan和inf导致溢出,inf表示无穷大
root.mainloop()

个人愚见,若有错误恳请批评指正。

你可能感兴趣的:(python,开发语言)