admin管理员组文章数量:1122846
I have a very weird issue affecting my code. I'm getting set up on a new machine, and in VS Code the Python terminal is passing different code than what I wrote in the editor. I'm not sure if there is a setting that I need to change, but I never had this issue on any of the other machines that I've worked on.
The terminal seems to be passing indentions that do not exist in the written code if I include the code in a function. All of this code is highlighted in the code editor and run by hitting Shift+Enter. When I run the function, it gives an Unexpected Indent error.
If I have the code:
var1 = 1
var2 = 2
print(var1+var2)
it works.
If I wrap it in a function:
def test_function():
var1 = 1
var2 = 2
print(var1+var2)
it does not.
When I look in the terminal, the code that is passed looks like this:
This is not the way the code is written:
I have ensured that the indention setting is set to four. I've tried this with both tabs and spaces.
The only thing that seems to work is if I remove all the white space, and now it works when I highlight it.
I have tried searching for settings to change, but nothing has worked.
Python 3.13.0 VS code 1.96.2
I have a very weird issue affecting my code. I'm getting set up on a new machine, and in VS Code the Python terminal is passing different code than what I wrote in the editor. I'm not sure if there is a setting that I need to change, but I never had this issue on any of the other machines that I've worked on.
The terminal seems to be passing indentions that do not exist in the written code if I include the code in a function. All of this code is highlighted in the code editor and run by hitting Shift+Enter. When I run the function, it gives an Unexpected Indent error.
If I have the code:
var1 = 1
var2 = 2
print(var1+var2)
it works.
If I wrap it in a function:
def test_function():
var1 = 1
var2 = 2
print(var1+var2)
it does not.
When I look in the terminal, the code that is passed looks like this:
This is not the way the code is written:
I have ensured that the indention setting is set to four. I've tried this with both tabs and spaces.
The only thing that seems to work is if I remove all the white space, and now it works when I highlight it.
I have tried searching for settings to change, but nothing has worked.
Python 3.13.0 VS code 1.96.2
Share Improve this question edited Jan 3 at 18:54 PM 77-1 13.3k21 gold badges70 silver badges115 bronze badges asked Jan 3 at 18:42 Stephen JuzaStephen Juza 2931 gold badge3 silver badges12 bronze badges 2 |1 Answer
Reset to default 1I am able to reproduce the problem on command prompt, Python version 3.13.1.
As vimchun said, switching to version 3.12.X will resolve the indentation issue.
本文标签:
版权声明:本文标题:New Python Instance in VS Code and the terminal is passing indentions that do not exist in the code editor window - Stack Overfl 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736449545a1944326.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
eol
configuration? – tdelaney Commented Jan 3 at 19:10