[英]How can I debug a python code in a virtual environment using VSCode?
[英]How do I debug stdin in vscode using python in linux?
我在 Ubuntu 上使用 VS Code,我編寫了這個簡單的 python 腳本來從終端讀取用戶輸入,只是為了了解標准輸入模式。 當標准輸入模式設置為“cbreak”(使用tty.setcbreak(sys.stdin.fileno())
)時,我想演示 sys.stdin 中的值。
我將 sys.stdin.read()、sys.stdin.readline() 和 sys.stdin.readlines() 添加到監視變量中,但我什么也沒得到。 變量顯示“不可用”,左上角的局部變量顯示正在加載。
如何觀看標准輸入?
下面是腳本和屏幕截圖。
import sys,tty,termios
old_attr=termios.tcgetattr(sys.stdin)
tty.setcbreak(sys.stdin.fileno())
input()
print("Exit")
termios.tcsetattr(sys.stdin,termios.TCSADRAIN,old_attr)
您在第 7 行添加了一個斷點。
您可以按 F5 繼續,這樣您就可以在終端中獲得 output。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.