我的问题很简单: usingpygame.draw和之间有什么区别pygame.gfxdraw?我查看了 pygame 文档,但没有人告诉他们它们之间的区别是什么。
我有一个代码来使用pygame绘制mandlebrot集.这是代码.
import pygame, sys, math
from decimal import *
window=pygame.display.set_mode((1000, 1000))
window.fill((255, 255, 255))
pygame.display.update()
winrect=window.get_rect()
hq=3
getcontext().prec=20
colors=((255, 0, 0), (255, 128, 0), (255, 255, 0), (128, 255, 0), (0, 255, 0), (0, 255, 128), (0, 255, 255), (0, 128, 255), (0, 0, 255), (128, 0, 255), (255, 0, 255), (255, 0, 128))
def graph(scale):#left, right, bottom, top
window.fill((0, 0, 0))
minimum=-1
y=((scale[3]-scale[2]))/(winrect.height)+scale[2]
for a in range(winrect.width):
x=((scale[1]-scale[0])*(a))/(winrect.width)+scale[0]
d, e=x**2-y**2+x, 2*x*y+y
for i in range(int(1/(50*(scale[1]-scale[0]))+25)):
d, e=d**2-e**2+x, 2*d*e+y
if …Run Code Online (Sandbox Code Playgroud) 在代码中,我试图检查输入函数的变量类的类型.我想要的是这样的:
def foo(x):
if type(x)=='int':
pass
Run Code Online (Sandbox Code Playgroud)
但我无法找到任何东西,我可以落实到位'int',将返回True当我输入一个整数.我做了一个临时修复type(x)==type(1),但我想知道如何不使用这个偷偷摸摸的技巧.
我试图以一种有效的方式列出一个列表,但我无法想出任何方法来避免引用.这是我到目前为止所尝试的,显然没有成功:
>>> test=[[None]*3][:]*3
>>> test
[[None, None, None], [None, None, None], [None, None, None]]
>>> test[0][0]=0
>>> test
[[0, None, None], [0, None, None], [0, None, None]]
>>>
Run Code Online (Sandbox Code Playgroud)
这不是我想要发生的事情.我想要的是0是第一个列表中的第一个项目.我怎样才能做到这一点?