命令“python 1-4-helloworld.py”启动运行了什么程序

命令“python 1-4-helloworld.py”启动运行了什么程序,第1张

启动了名为helloworld的脚本文件。

以py为后缀名的文件是python坏境下的专属脚本,这种脚本一般用于软件的安装。

python在执行时,会将.py文件中的源代码编译成python的byte code,再由Python Virtual Machine来执行这些编译好的byte code。

1、首先打开Python交互式环境,打开CMD或powershell输入“python”指令,即可看到出现“>>>”,即意味着进入Python交互式环境

2、然后Python交互式环境中输入“print('Hello World')”,按下回车即可看到控制台打印出来的Hello World字符串,这就是最简单的Python程序。

3、 最后在Python交互式环境中输入“exit()”指令即可退出Python交互式环境。

保存为helloworld.py后,执行 chmod +x helloworld.py,然后运行 ./helloworld.py或者python helloworld.py,如果是windows *** 作系统,直接在命令行下执行 python helloworld.py即可,注意事先配置好环境变量。。配置好的效果如下:

C:\Users\Administrator>python

Python 2.6 (r26:66721, Oct 2 2008, 11:35:03) [MSC v.1500 32 bit (Intel)] on win

32

Type "help", "copyright", "credits" or "license" for more information.

>>>print 'hello world'

hello world

>>>


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/yw/11534876.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-05-16
下一篇 2023-05-16

发表评论

登录后才能评论

评论列表(0条)

保存