![](/img/trans.png)
[英]My Visual Studio Code is not using the Python interpreter that I have set it to
[英]In Visual Studio Code, I want to pass a parameter(e.g. -i) to the Python interpreter when I debug/run my code
我開始學習 Python 編程,我想運行我的代碼,然后使用 Python 解釋器中的“-i”選項來玩它。 但是,當我在 launch.json 文件中定義 "args": ["-i"] 時, -i 反而成為我的程序的參數。
有什么方法可以將“-i”作為參數傳遞給 Visual Studio Code 中的 Python Interpreter?
例如:
# test.py
dict = [{'name': 'AA', 'price': 32.2, 'shares': 100},
{'name': 'IBM', 'price': 91.1, 'shares': 50},
{'name': 'CAT', 'price': 83.44, 'shares': 150}]
跑
>python.exe -i test.py
>>>dict = [{'name': 'AA', 'price': 32.2, 'shares': 100},
{'name': 'IBM', 'price': 91.1, 'shares': 50},
{'name': 'CAT', 'price': 83.44, 'shares': 150}]
>>>
我設法通過使用 launch.json 生成的先前命令來解決問題,復制並粘貼然后添加“-i”。 我認為它不能在調試模式下使用。
您也可以使用其他 python 選項和 arguments (如“-d”)來執行此操作
我不知道 Python 是否支持它,但請嘗試使用runtimeArgs
而不是Args
。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.