我正在NumPy中处理3d数组,我必须大量研究数组元素。说我有阵a哪里a.shape是(10,5,3)。我正在使用的是3个形状平面的感觉(10,5),我想这样看。
例如,如果我
print(a)
Run Code Online (Sandbox Code Playgroud)
我懂了
[[[ 0 0 0]
[ 0 0 0]
[ 0 0 0]
[ 0 0 0]
[ 0 0 0]]
[[ 0 0 0]
[ 0 22 0]
[11 22 33]
[ 0 0 0]
[ 0 0 0]]
[[ 0 0 0]
[11 22 33]
[ 0 0 0]
[11 22 33]
[ 0 0 0]]
[[ 0 0 0]
[11 22 33]
[ 0 0 0] …Run Code Online (Sandbox Code Playgroud) 我正在 Tkinter 画布中开发一个游戏,其中点在屏幕上移动。我将每个点放在一个位置,tkinter.Canvas.create_oval(...)然后用 移动这些点tkinter.Canvas.move(pointID,delta_x,delta_y)。
我的问题是这些点在移动时似乎会留下痕迹。我做了一个简单的例子来演示我的问题。
from tkinter import Canvas,mainloop,Tk
import numpy as np
import random
import traceback
import threading
import time
from queue import Queue
class Point:
def __init__(self,the_canvas,uID):
self.uID = uID
self.location = np.ones((2)) * 200
self.color = "#"+"".join([random.choice('0123456789ABCDEF') for j in range(6)])
self.the_canvas = the_canvas
self.the_canvas.create_oval(200,200,200,200,
fill=self.color,outline=self.color,width=6,
tags=('runner'+str(self.uID),'runner'))
def move(self):
delta = (np.random.random((2))-.5)*20
self.the_canvas.move('runner'+str(self.uID),delta[0],delta[1])
def queue_func():
while True:
time.sleep(.25)
try:
next_action = the_queue.get(False)
next_action()
except Exception as e:
if str(e) != "":
print(traceback.format_exc())
the_queue …Run Code Online (Sandbox Code Playgroud)