简体   繁体   English

如何运行在文本编辑器中编写的代码?(sublime2)

[英]How do I run the code I've written in my text editor?(sublime2)

Sorry for the really basic question, but my web searches have yielded poor results. 抱歉,我的基本问题很严重,但是我的网络搜索结果不佳。 I'm trying to make a simple text game right now and I know that my code is definitely wrong, but I want to try and run it and see what kind of feedback it gives to me. 我现在正在尝试制作一个简单的文字游戏,我知道我的代码肯定是错误的,但是我想尝试并运行它,看看它会给我带来什么样的反馈。 I've searched and found that ctrl + B is supposed to compile and run the code, but I get an error saying "The system cannot find the file specified". 我已经搜索并发现ctrl + B应该可以编译并运行代码,但是出现错误消息“系统找不到指定的文件”。 I have other programs such as the Python cmnd line and Vim but I'm not sure if they don't seem to help either. 我有其他程序,例如Python cmnd line和Vim,但是我不确定它们是否也没有帮助。 I'm the absolute epitome of the word beginner, so any help is definitely appreciated. 我是“初学者”一词的绝对缩影,因此,我们非常感谢您的帮助。 Thank you so much! 非常感谢!

On whatever OS(Linux/Windows/Mac OS), you can use command line to run your python script. 在任何操作系统(Linux / Windows / Mac OS)上,都可以使用命令行运行python脚本。

With something like: 用类似的东西:

    python xxx.py

If it says python not found, then you don't have python installed correctly OR it's not in the system PATH. 如果显示未找到python,则说明您没有正确安装python,或者它不在系统PATH中。 Then search for how to add it to PATH. 然后搜索如何将其添加到PATH。

First I would recommend using your file manager in to find the path to your file, for example in OSX you simply right click on your python file and select get info. 首先,我建议您使用文件管理器查找文件的路径,例如,在OSX中,您只需右键单击python文件并选择获取信息。 If you discover the path to your file is ~/foobar/foo/bar.py, you should open up terminal and run 如果发现文件的路径是〜/ foobar / foo / bar.py,则应打开终端并运行

python ~/foobar/foo/bar.py python〜/ foobar / foo / bar.py

Hope this it explains it. 希望它能解释它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM