Cov txheej txheem:

Koj tuaj yeem hla dhau Python code?
Koj tuaj yeem hla dhau Python code?

Video: Koj tuaj yeem hla dhau Python code?

Video: Koj tuaj yeem hla dhau Python code?
Video: Mathematics with Python! Sequences 2024, Tej zaum
Anonim

Python Debugger Commands

Yog koj ua haujlwm nrog Python , tsis yog xwb tau koj saib dhau tus code thaum debugging, tab sis koj ua tau kuj khiav cov code uas tau sau rau hauv kab hais kom ua lossis txawm cuam tshuam cov txheej txheem los ntawm kev hloov pauv cov nqi sib txawv. Python muaj ib tug built-in debugger hu ua pdb

Yog li ntawd, koj yuav ua li cas debug kab los ntawm kab hauv Python?

Qee qhov tseem ceeb uas yuav tsum nco ntsoov yog:

  1. b: set ib breakpoint.
  2. c: txuas ntxiv debugging kom txog rau thaum koj ntaus lub breakpoint.
  3. s: kauj ruam dhau lub chaws.
  4. n: mus rau kab tom ntej no code.
  5. l: sau qhov chaws rau cov ntaub ntawv tam sim no (default: 11 kab nrog rau kab raug tua)
  6. u: navigate ib pawg ncej.
  7. d: mus rau hauv ib pawg ncej.

Kuj Paub, dab tsi yog qhov breakpoint hauv Python? Python breakpoint () yog ib tug tshiab built-in muaj nuj nqi qhia nyob rau hauv Python 3.7. Python code debugging yeej ib txwm ua tus txheej txheem mob vim yog nruj coupling ntawm tiag code thiab debugging module code. Piv txwv li, yog tias koj siv pdb debugger, ces koj yuav tau hu rau pdb. set_trace() hauv koj qhov program code.

Tsis tas li ntawd, kuv yuav ua li cas thiaj li khiav Python tsab ntawv kab los ntawm kab?

Siv python commandQhov yooj yim tshaj plaws thiab txoj kev yooj yim rau khiav Python scripts yog los ntawm kev siv lub python lus txib. Koj yuav tsum qhib qhov hais kom ua- kab thiab ntaus lo lus python ua raws li txoj kev mus rau koj tsab ntawv file, zoo li no: python first_script.py Nyob zoo ntiaj teb no! Tom qab ntawd koj ntaus lub pob ENTER los ntawm cov keyboard thiab qhov ntawd yog nws.

Kuv yuav ua li cas debug Python code hauv Visual Studio?

Xaiv cov cuab yeej> Xaiv cov ntawv qhia zaub mov hais kom ua, mus rau Python > Kev debugging , thiab xaiv qhov Use legacy debugger kev xaiv. Yog hais tias koj tau nruab ib tug laus version ntawm ptvsd nyob rau hauv lub tam sim no ib puag ncig (xws li ib tug ua ntej 4.0. x version, los yog ib tug 3. x version yuav tsum tau rau tej thaj chaw deb debugging ), Visual Studio tej zaum yuav qhia qhov yuam kev lossis ceeb toom.

Pom zoo: