編輯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變量的信息