• jupyter巨好玩-调试代码自动变文档


    有时候,我们写python程序,总是会出现各种错误,当酒过三巡,菜过五味,所有问题都解决了之后,我们就想把犯过的错误总结一下,以便日后查询。这时候问题来了,难道要一一重现一下?

    jupyter来了!一切都解决了,这就是个代码摄像机啊,写代码时候出错了,一堆错误提示,没关系,从新插入一个cell,再次写起来!直到正确为止!

    第一个错误

    # 假装我不会写helloworld
    print hello world
    
    
      File "<ipython-input-1-e9edef3fb57e>", line 2
        print hello world
                        ^
    SyntaxError: invalid syntax
    

    第二个错误

    # 难道加个引号?
    print 'hello world"
    
      File "<ipython-input-2-efbc3c88a80d>", line 2
        print 'hello world"
                          ^
    SyntaxError: EOL while scanning string literal
    

    啥情况?引号也不行?!

    好吧,原来要写一对啊!

    终于

    # 这次对了吧?你好!世界!
    print 'hello world'
    
    hello world
    

    ok,写到这里,错误代码有了,错误信息有了,最终也有了正确代码,咱们发布博客吧!

    用vscode发布

    • 另存为md文件
    • vscode打开
    • 用writecnblog插件发布

    具体步骤请查看上篇博客。
    http://www.cnblogs.com/howiewang/p/ipython-write-blog.html

  • 相关阅读:
    单表查询
    解读python中SocketServer源码
    C++实训(2.3)
    C++实训(2.2)
    C++实训(2.1)
    C++实训(1.3)
    C++实训(1.1)
    顺序表的实现,在vs2019上运行成功
    p243_5(3)
    自考新教材-p176_5(2)
  • 原文地址:https://www.cnblogs.com/de8ug/p/ipython-debug-python.html
Copyright © 2020-2023  润新知