microsoft / vscode

Visual Studio Code
https://code.visualstudio.com
MIT License
164.13k stars 29.27k forks source link

The python code result is displayed incorrectly #232217

Open frant1122 opened 2 weeks ago

frant1122 commented 2 weeks ago

Type: Bug

def demo1(): import math number=eval(input('输入一个数:')) if number<0: output=abs(number) elif number<5: number1=numbermath.pi/180 output=pow(math.e,number)math.cos(number1) elif number<10: output=number*3 else: output=(7+8number)*math.log(number) print(output) if isinstance(output,int) else print("{:.2f}".format(output)) print(output if isinstance(output,int) else "{:.2f}".format(output)) demo1() When I entered 5.696, the code result was184.8 instead of 184.80,even though the code was correct.

VS Code version: Code 1.93.1 (38c31bc77e0dd6ae88a4e9cc93428cc27a56ba40, 2024-09-11T17:20:05.685Z) OS version: Windows_NT x64 10.0.22621 Modes:

System Info |Item|Value| |---|---| |CPUs|13th Gen Intel(R) Core(TM) i7-13620H (16 x 2918)| |GPU Status|2d_canvas: enabled
canvas_oop_rasterization: enabled_on
direct_rendering_display_compositor: disabled_off_ok
gpu_compositing: enabled
multiple_raster_threads: enabled_on
opengl: enabled_on
rasterization: enabled
raw_draw: disabled_off_ok
skia_graphite: disabled_off
video_decode: enabled
video_encode: enabled
vulkan: disabled_off
webgl: enabled
webgl2: enabled
webgpu: enabled
webnn: disabled_off| |Load (avg)|undefined| |Memory (System)|15.63GB (8.08GB free)| |Process Argv|--crash-reporter-id 97d15a35-4c33-404b-b857-7093f30a7890| |Screen Reader|no| |VM|0%|
Extensions (9) Extension|Author (truncated)|Version ---|---|--- better-comments|aar|3.0.2 project-manager|ale|12.8.0 code-runner|for|0.12.2 vscode-language-pack-zh-hans|MS-|1.94.2024101609 debugpy|ms-|2024.12.0 python|ms-|2024.14.1 vscode-pylance|ms-|2024.10.1 indent-rainbow|ode|8.3.1 errorlens|use|3.20.0
A/B Experiments ``` vsliv368:30146709 vspor879:30202332 vspor708:30202333 vspor363:30204092 vscod805cf:30301675 binariesv615:30325510 vsaa593cf:30376535 py29gd2263:31024239 vscaat:30438848 c4g48928:30535728 azure-dev_surveyonecf:30548226 2i9eh265:30646982 962ge761:30959799 pythongtdpath:30769146 pythonnoceb:30805159 asynctok:30898717 pythonmypyd1:30879173 h48ei257:31000450 pythontbext0:30879054 cppperfnew:31000557 dsvsc020:30976470 pythonait:31006305 dsvsc021:30996838 f3je6385:31013174 dvdeprecation:31068756 dwnewjupytercf:31046870 impr_priority:31102340 nativerepl1:31139838 refactort:31108082 pythonrstrctxt:31112756 wkspc-onlycs-t:31132770 wkspc-ranged-t:31151552 cf971741:31144450 defaultse:31146405 iacca1:31156133 notype1cf:31157160 5fd0e150:31155592 dwcopilot:31164048 iconenabled:31158251 ```
karthiknadig commented 2 weeks ago

Where are you running this? In the VS Code terminal I get: Image

frant1122 commented 2 weeks ago

Where are you running this? In the VS Code terminal I get: Image

I don't know what's wrong with my VSCode。I had tried it many times。 I'm going to try it once again。Hope everything will go well。

karthiknadig commented 2 weeks ago

This is likely not a VS Code issue. Try this in a terminal outside of VS Code. If you are seeing this in external terminal then it is likely something to do with environment variables.

frant1122 commented 2 weeks ago

这可能不是 VS Code 问题。在 VS Code 之外的终端中尝试此操作。如果您在外部终端中看到此内容,则可能与环境变量有关。、、 The problem has been solved. Dramatically,I restarted my computer,opened VSCode and rerunned my program,only to find that the result was CORRECT! I think maybe the vscode had suffered from some unknowen errors. But I must thank you for answering my problem and offering some constructive suggestions which have helped me,a Chinese university student,a lot.