简体   繁体   中英

how to input from python debugger pdb

This question may be trivial, but I am new to Python. The question is best to illustrate by the following simple example. I am using pdb to debug the following script (it is python 3):

astring = input("input here: ")

when step in above line, I get the following prompt and type "abc"

input here: abc

but whatever I input from keyboard, I get error eg

NameError: "name 'abc' is not defined"
> /home/wang/tmp/test.py(4)<module>()
-> astring = input("input here: ")

How can I input when debugging? Thanks a lot!

您在Python 2上出于目的使用了错误的函数。使用raw_input而不是input

It seems that the "abc" entered is considered an evaluation. However, You program is input("input here "), but the example you give is "input here:" and the output from pdb says "input a line:", I don't know whether they are they same program due to these differences. Try entering n (for next line of code) instead of abc and see what happens.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM