我想创建一个与此类似的图形。是否可以使用matplotlib / seaborn。如果是这样,我可以使用哪些资源来学习如何设置matplotlib / seaborn图的样式以及如何使两个图像这样排列。
我正在尝试list()
在课堂上打电话时返回一个列表.什么是最好的方法.
class Test():
def __init__(self):
self.data = [1,2,3]
def aslist(self):
return self.data
a = Test()
list(a)
[1,2,3]
Run Code Online (Sandbox Code Playgroud)
我想要什么时候list(a)
调用它来运行该aslist
函数,理想情况下我想实现asdict
它在dict()
调用时有效
我希望能够与做到这一点dict
,int
和所有其他类型转换
我正在尝试使用pygame,并尝试创建一个类似的类.
import pygame
from threading import Thread
gameExit = True
class states:
def __init__(self):
gameDisplay = pygame.display.set_mode((800, 600))
pygame.display.set_caption('test')
clock = pygame.time.Clock()
renderThread = Thread(target=self.render, args =(gameDisplay))
updateThread = Thread(target=self.update, args = (clock))
updateThread.start()
renderThread.start()
def update(self, clock):
global gameExit
while gameExit:
print('update')
clock.tick(30)
def render(self, gamedisplay):
global gameExit
print('render')
while gameExit:
print('render')
gameDisplay.fill([255, 255, 255]) # clearing
pygame.display.update()#update
state = states()
Run Code Online (Sandbox Code Playgroud)
错误代码是渲染()*后的参数必须是一个可迭代,不pygame.Surface为什么不会它通过传递gameDisplay /我该怎么办呢?
这是完整的追溯:
Exception in thread Thread-2:
Traceback (most recent call last):
File "C:\Users\Marc Frame\AppData\Local\Programs\Python\Python35\lib\threading.py", line 914, in …
Run Code Online (Sandbox Code Playgroud)