当前位置: 移动技术网 > IT编程>脚本编程>Python > python - jupyter 代码运行时清屏

python - jupyter 代码运行时清屏

2020年07月16日  | 移动技术网IT编程  | 我要评论

jupyter notebook清除输出

###############################################################
# 这里就是jupyter的运行时清屏函数,虽然不知道什么原理,回头再来学
import sys
import os
def clear_output():
    """
    clear output for both jupyter notebook and the console
    """
    os.system('cls' if os.name == 'nt' else 'clear')
    if 'ipykernel' in sys.modules:
        from IPython.display import clear_output as clear
        clear()
###############################################################

list_return_str=[]
list_return_bool=[]
list_other=[]
for methods in dir(str):
    exec("help(str.%s)"%methods)
    c=input()
    # 这里我其实想搞一个按一下就自动选择运行的,但是那个键盘监控的功能很高深的样子,所以就仍按一下又一下的做法吧!
    if c=="'": list_return_str.append("str.%s"%methods)
    elif c=="\\":list_return_bool.append("str.%s"%methods)
    else:list_other.append("str.%s"%methods)
    clear_output()

因为我想把str的方法分类,那种返回字符串的,判断的,以及其他的!所以有了上面的函数

本文地址:https://blog.csdn.net/jhsxy2005/article/details/107367932

如对本文有疑问, 点击进行留言回复!!

相关文章:

验证码:
移动技术网