在 Anaconda 中保存并打开 Python 脚本

Saving and opening Python Script in Anaconda

我使用 Anaconda 和安装在 Anaconda 中的 Spyder 来学习 python。

问题:当我尝试通过将文件名扩展为 .py 来保存 python 脚本时,python 脚本会自动保存在 Windows 记事本中。当我尝试在 Spyder 中再次打开它时,它打不开。

换句话说,在 Spyder 中,我通过执行“文件 - 另存为 - 'filename.py'”来保存脚本 我试图通过在 Spyder 中执行“文件 - 打开 - 'filename.py'”来打开保存的脚本。

然而,它不起作用。

我有两个问题。

  1. python脚本保存在windows记事本上正常吗?如果不是,这里有什么问题?您通常如何使用 Anaconda 保存 python 脚本?

  2. 为什么 Spyder 打不开记事本文件,即我保存的 python 脚本?我在保存时添加了扩展名 .py,但无论如何它都没有在 Anaconda Spyder 中打开。

我知道这对很多人来说都是一个基本问题,答案可能存在于某个地方,但我很难找到它,我希望有人能帮助我解决这个问题。谢谢

第一个问题的答案
python 脚本保存在windows 记事本上正常吗?如果不是,这里有什么问题?您通常如何使用 Anaconda 保存 python 脚本?

Check what default program is set for opening .py file in your system you can change it by
rightclicking on .py file >expand open with > choose open with another app and tick the option 'always use this for .py file'

第二个问题
为什么 Spyder 不打开记事本文件,即我保存的 python 脚本?我在保存时添加了扩展名 .py,但无论如何它都没有在 Anaconda Spyder 中打开。

Check type of file your saving "the field below filename it should be allfiles(*)" probably your script is saving "filename.py.txt" which is not a proper format for python file