PyCharm Debug 调试

PyCharm Debug 调试

编辑python脚本,debug.py
#!/usr/bin/env python
# -*- coding:utf-8 -*-
# @Time   : 2017/10/17 21:46
# @Author : lijunjiang
# @File   : test.py

def hello():
    return 'hello'

if __name__ == '__main__'
    print('###' * 10)
    name = raw_input("Please input your name: ")
    print(hello() + name)
    print('###' * 10)
设置断点 在行号后单击(双击取消)

F8 跳过

Alt + Shift + F9 运行debug模式

程序执行到第一个断点处停止,执行了两次 print('###' * 10)

按F8,执行下一行代码

按F8 执行到 name = raw_input("Please input your name: ") 处,按提示输入

接着按F8 会执行 print(hello() + name) 并跳到下一行

F7 进入

Alt + Shift + F9 运行debug模式 在断点处停止

按F8 执行到 name = raw_input("Please input your name: ") 处,输入姓名

此时按F7

会发现进入到了def hello() 函数中,接着按F8会逐行执行函数内的代码,直致执行完成,跳出函数

F9 只在断点和交互处停止,快速调式

两个断点

shift + f9 运行debug模式 停止在第一个断点处

f9 停止在第二个断点处

再F9 停止在交互处

输入后回车 运行到脚本结束


两种模式 Debuger模式 console 模式

console模式

如上面所看到的即为console模式,类似于命令行的出输,可以直观的看到程序每行代码运行的效果

Debuger 模式

如图:

按F8 使程序运行到 name = raw_input("Please input your name: ") 并输入姓名

进入Debuger模式, 可以看到 name = (str) 'lijunjiang'

查找变量

点击Debuger模式的图标,输入  即可查看name变量的信息

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值