0

第一个Python程序

 3 years ago
source link: https://blog.csdn.net/qq_52617588/article/details/113100664
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

第一个Python程序

original.png
Pachimarii 2021-01-26 01:16:28 articleReadEyes.png 543
文章标签: python

第一个Python程序Hello world

本篇文章将帮助你完成你利用python 输出Hello world。若有不足,欢迎各位批评指正。

开发环境的安装与运行

可以使用解释器自带的环境(idle)或者集成开发环境(anaconda、pycharm、Visual Studio、Elipse)
1.可以前往python官网下载python官方的解释器,利用idle完成代码量较小的任务,特别适合初学者。点击Downloads
1)点击Downloads
点击Windows
2)点击Windows
选择你需要的python版本

3)选择你需要的python版本,现在一般都选择python3而不是python2。python3是未来的主流,而且python2与python3不兼容,使用时需要注意。根据自身操作系统配置选择32位或者64位安装包。若下载速度较慢,可以右键复制embeddable package链接,然后到迅雷粘贴下载。

在这里插入图片描述
4)下载完成后运行,选择Customize installation同时勾选 Add Python 3.7 to PATH(选择的版本不同,会导致其名称有所差异),这样做之后在cmd命令提示符可以调用python。之后出现的对话框点击next,最后直接选择close。

在这里插入图片描述
5)左下角搜索idle,回车运行即可。在这里插入图片描述

2.其他常用的集成开发环境如: Anaconda3 & Spyder免费集成开发工具 ;PyCharm集成开发工具,分为Professional和Community(免费);Visual Studio集成开发工具,分为Community(个人可免费用于学术用途)、Professional(个人的免费试用版)和Enterprise(供组织使用的免费试用版)。
以Visual Studio Community2019为例子
官网
1)鼠标悬停在 下载Visual Studio,选择Community2019。在这里插入图片描述
2)下载完成运行后,在工作负载选择Python开发,可在安装位置 自定义位置,单击下一步。在这里插入图片描述
3)启动 Visual Studio,创建新项目。
在这里插入图片描述
4)选择python应用程序,单击下一步在这里插入图片描述
5)自定义名称和位置,单击创建即可。

Hello world

刚刚开始学习一门高级语言,忘不了的就是Hello world。
1.利用python解释器自带的开发环境idle,输入
print("Hello world")
回车在这里插入图片描述
2.上一条是交互式操作,如果我们想执行多条语句,可以使用文件式操作,将多条语句写入到一个文件当中。

1)左上角File—>New File,输入
print("Hello") print("world")
在这里插入图片描述
2)点击save,选择保存地址并输入自定义文件名,以 .py为后缀。在这里插入图片描述
3)文件式运行可以在idle中,单击run运行。在这里插入图片描述
3.另外,也可以使用cmd命令提示符输入“python+空格+文件绝对路径”实现。


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK