Python 2.7 如何在Jupyter中显示单元格编号?
我想知道如何在Jupyter笔记本中显示手机号码 动机:Python 2.7 如何在Jupyter中显示单元格编号?,python-2.7,jupyter-notebook,Python 2.7,Jupyter Notebook,我想知道如何在Jupyter笔记本中显示手机号码 动机: 我正在使用nbformat显示Jupyter笔记本中的信息 要检索文本和图像信息,我目前依赖于执行计数值,如下所示: def select_cell(notebook, out_value): """ returns the information of a cell """ # Notebook formatting defintions if notebook["nbformat"] <
我正在使用
nbformat
显示Jupyter笔记本中的信息
要检索文本和图像信息,我目前依赖于执行计数
值,如下所示:
def select_cell(notebook, out_value):
"""
returns the information of a cell
"""
# Notebook formatting defintions
if notebook["nbformat"] < 4:
cell_all = list(notebook["worksheets"][0]["cells"])
key_counter = 'prompt_number'
else:
cell_all = list(notebook["cells"])
key_counter = 'execution_count'
# Finding and returning the relevant cell
for icell, cell in enumerate(cell_all):
try: # Not all Cells have the `key_counts`
if cell[key_counter] == out_value:
return cell
except:
None
return None
def选择单元(笔记本,输出值):
"""
返回单元格的信息
"""
#笔记本格式定义
如果笔记本[“nbformat”]<4:
单元\全部=列表(笔记本[“工作表”][0][“单元”])
键\u计数器='提示\u编号'
其他:
单元\全部=列表(笔记本[“单元”])
键\计数器='执行\计数'
#查找并返回相关单元格
对于icell,枚举中的单元格(单元格\全部):
try:#并非所有单元格都有“键”计数`
如果单元格[键计数器]==输出值:
返回单元
除:
没有一个
一无所获
通过out\u value
我指的是笔记本左边空白处方括号中的数值,上面写着“out[out\u value]:”和
notebook=nbformat.read(文件\u notebook,4)
我认为最好让select\u cell
根据实际单元格值返回单元格,而不是循环返回。特别是因为每次执行时,out\u值
都会更新,其中单元格值是恒定的
是的,你可以数一数手机号码,但如果是一个长笔记本,你很容易就会忘记