Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在使用pysandbox在沙盒环境中运行 Python 代码。我启动并运行它,但我希望它支持 pythondatetime模块。根据文档,我在配置中添加了“日期时间”,如下所示,
datetime
sandbox = SandboxConfig('datetime', cpython_restricted=False)
但是如果我运行代码我仍然会得到错误,
'未定义全局名称日期时间'
pysandbox 存在一些问题。看起来您正在通过locals变量将一些参数传递给沙盒函数。在这种情况下,导入不会添加到全局命名空间。
locals
global datetime只需在导入后立即编写即可。否则,您也可以将其作为函数参数传递。
global datetime
我尝试使用下面的代码来解析 JSON 数据,该网站需要一个 API 密钥,现在它作为字符串存储在我的 strings.xml 中。
public class JSONParser { static InputStream is = null; static JSONArray jarray = null; static String json = ""; // const