在 PyCharm 中命名一个新文件 [英] Naming a new file in PyCharm

查看:34
本文介绍了在 PyCharm 中命名一个新文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚开始学习python.到目前为止,我主要使用 jupyter 笔记本,但现在想尝试一些 IDE.所以我尝试了 PyCharm.

所以我开始在一个项目中创建一些文件并开始尝试命令和东西,有一件事情让我发疯,因为我似乎找不到答案.

每次我创建一个新的 python 文件并将其命名为simple_message"时,它只是保存为普通文件,我无法在其中运行任何代码.删除下划线后,文件约定将更改为实际的 python 文件,我可以运行其中编写的代码.所以我认为可能是下划线造成了麻烦,所以我尝试使用下划线创建其他文件,但它们都有效.有人可以启发我,为什么文件名simple_message"不能作为python文件工作?

谢谢!

I just started learning python. Up until now, I primarly worked with jupyter notebooks, but now wanted to try out some IDEs. So I tried out PyCharm.

So I started creating some files in a project and started trying out the commands and stuff and there is one thing which just drives me crazy, cause I can not seem to find an answer.

Everytime I create a new python file and name it something like "simple_message", it just saves as a normal file and I can't run any code in it. As soon as I remove the underscore, the file convention changes to an actual python file and I can run the code written in it. So I thought it might be the underscore that makes trouble, so I tried creating other files with underscores but all of them worked. Can someone enlighten me, why does the file name "simple_message" not work as a python file?

Thank you!

From this To this

解决方案

Currently PyCharm context menu lets you choose the file type to create. If you choose "file" you MUST provide the extension .py If You choose "Python File" pycharm handles the extension for You.

这篇关于在 PyCharm 中命名一个新文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆