How do I change a value while debugging python with pdb?

前端 未结 2 1015
别跟我提以往
别跟我提以往 2021-02-07 07:46

I want to run pdb, step through the code, and at some point change the value pointed at by some name. So I might want to change the value pointed at by the name \'stationLat\'

2条回答
  •  深忆病人
    2021-02-07 08:10

    Actually, the value of the variable does get changed when you assign a new value in pdb. But if you try to read the variable in pdb again without running your code, it may reset to the original value.

    If you step back into your code, you should see that it will use your new value (-40).

    Try this:

    stationLat = -40
    s # step back into code
    stationLat # should display -40
    

提交回复
热议问题