python - 我在 Mac 中 Visual Studi Code 中的 Python 代码一直运行相同的代码
问题描述
所以,我是 Python 的新手(通常是编程),我确实在 Visual Studio 代码中下载了 Python 3.7、Visual Studio Code、Python、代码运行器扩展,并创建了 python 文件并运行了一个代码(打印('me')),之后我对代码进行了更改,例如 print ('him') ,它仍然运行 'me' 而不是 'him' 。我不确定为什么。只有当我打开一个新文件并保存它时它才有效。但我不想那样做。我想对现有的 python 文件进行更改,而不是每次都创建一个新文件。
我确实按照该用户在 Youtube 上给出的安装说明进行操作。看来我安装正确。
解决方案
It seems like you did not actually save your changes. It is important to understand what is happening when you "edit" a file. Your file is "saved" on your computer's hard drive (somewhere). That is what is being run when you press run -- the saved file.
If you have your "old code", your (print ('me'))
, change that to (print ('hello world'))
and navigate to File -> Save
in Visual Studio Code. From there, try running that file from within VSCode. See what happens.
When you open it in VisualStudioCode, you are not actually editing that file that is saved on your hard drive! Your computer has placed a temporary copy of it in your computer's memory, which is what is being edited. Therefore, if you want to run your edited code, you need to Save the file you are editing. It is common practice to use keyboard shortcuts, like Commmand + S
to do that easier.
If you are interested in enabling autosave, to avoid needing to manually save, you can find more details on how to do that at this visual studio documentation link
推荐阅读
- yaml - Yaml 不会验证
- python - 如何使用引用错误更新 if else 语句中的变量
- sql - SQL - CASE WHEN 结果输出冲突结果
- google-sheets - 多个条件下的 Google 表格数组公式匹配,1 是小于或等于的日期
- reactjs - 如何处理 Uncaught(在 Promise 中):Apollo 客户端中的错误
- css - 父母和孩子的缩放转换导致抖动
- reactjs - 将 React 组件库构建到 CDN 而不是 NPM
- spring-kafka - RetryingBatchErrorHandler - 偏移提交处理
- wso2 - 如何将硬编码端口更改为 deployement.toml 中的环境名称?
- c - 在C中连接字符串和数字