因此,我編寫的代碼工作正常,但不斷彈出警告。我不知道這意味著什么以及如何處理它。警告如下:Warning (from warnings module): File "C:/Users/LENOVO/Desktop/GROOT!/ch.py", line 41 win.blit(char, (x, y))DeprecationWarning: an integer is required (got type float). Implicit conversion to integers using __int__ is deprecated, and may be removed in a future version of Python.我不知道我是否需要更改我的代碼中的某些內容。請告訴我我需要做什么。
2 回答

慕雪6442864
TA貢獻1812條經驗 獲得超5個贊
警告意味著x
和/或y
具有浮點值但blit()
(以及 PyGame 中的其他函數)需要整數值。你可以用int(x), int(y)
它來改變它
win.blit(char, (int(x), int(y)))
警告還告知這次它會自動將其轉換為整數,但在下一個 PyGame 版本中它可能不會這樣做,最好int()
手動使用。

一只斗牛犬
TA貢獻1784條經驗 獲得超2個贊
要么你使用靜音這個警告
import warnings warnings.filterwarnings('ignore', category=Warning)
或者您將 x 和 y 轉換為 int 使用int(x), int(y)
添加回答
舉報
0/150
提交
取消