代码拉取完成,页面将自动刷新
# Query Jupyter server for defined variables list
# Tested on 2.7 and 3.6
import json as _VSCODE_json
# In IJupyterVariables.getValue this '_VSCode_JupyterTestValue' will be replaced with the json stringified value of the target variable
# Indexes off of _VSCODE_targetVariable need to index types that are part of IJupyterVariable
_VSCODE_targetVariable = _VSCODE_json.loads("""_VSCode_JupyterTestValue""")
_VSCODE_evalResult = eval(_VSCODE_targetVariable["name"])
# Find shape and count if available
if hasattr(_VSCODE_evalResult, "shape"):
try:
# Get a bit more restrictive with exactly what we want to count as a shape, since anything can define it
if isinstance(_VSCODE_evalResult.shape, tuple):
_VSCODE_shapeStr = str(_VSCODE_evalResult.shape)
if (
len(_VSCODE_shapeStr) >= 3
and _VSCODE_shapeStr[0] == "("
and _VSCODE_shapeStr[-1] == ")"
and "," in _VSCODE_shapeStr
):
_VSCODE_targetVariable["shape"] = _VSCODE_shapeStr
del _VSCODE_shapeStr
except TypeError:
pass
if hasattr(_VSCODE_evalResult, "__len__"):
try:
_VSCODE_targetVariable["count"] = len(_VSCODE_evalResult)
except TypeError:
pass
print(_VSCODE_json.dumps(_VSCODE_targetVariable))
del _VSCODE_json
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。