如何创建全局变量?

How to create global variables?

我需要创建一个变量(浮点数数组),python 控制器可以访问和修改该变量。如果你想知道我为什么需要这个,我正在尝试实现神经进化,我需要存储神经网络参数。我是 python.

的新手

Blender 中有一个可全局访问的字典 (https://docs.python.org/2/tutorial/datastructures.html)。

它带有 GameLogic 库,名为 globalDict

http://wiki.gameblender.org/index.php?title=GlobalDict

用法:

import GameLogic

...

GameLogic.globalDict['Key'] = value

...

value = GameLogic.globalDict['Key']