Learning Python 001 第一个程序

本文介绍如何使用PyCharm创建并运行简单的Python程序。通过实例演示了基本的算术运算,并对比了直接运行脚本与使用print函数的区别。

Python 第一个程序

我使用的开发工具是PyCharm软件。我们使用的是Python3.5 for windows

如果你还没有安装PyCharm软件 和 Python3.5,请到这里来看如果安装PyCharm软件和Python3.5

然后在PyCharm软件中新建一个项目,选中Python3.5库作为使用库。

在项目中,新建一个demo.py文件。输入下面的代码:

print(120 - 20 - 50)

使用PyCharm软件的好处就在于它自动补全功能,并且软件内部就有一盒终端。这个终端的使用说明,是根据系统而定的。如果你使用的是Ubuntu 或者 Max电脑,那么终端的使用方法和Linux终端的使用方法一样;如果你使用的是Windows电脑,那么终端的使用方法和cmd终端的使用方法一样。

运行程序
对着demo.py文件右键,点击Run ‘demo’。或者直接按Ctrl + Shift + F10快捷键。

这里写图片描述

或者在终端中运行。在PyCharm软件下方,有一个Terminal栏,

这里写图片描述

把它打开,现在我们是在Window系统的电脑上,所以这个终端就是cmd终端。(我习惯将Terminal栏拖到PyCharm软件的右侧。)

>python demo.py 
50

或者,直接输入demo.py

>demo.py 
50

如果你在程序中这样写:

120 - 20 - 50

在运行Python脚本的时候,是没有任何输出的。

Python中,管.py文件叫脚本文件,或者脚本程序,不能只叫它程序


直接在终端中输入python,是进入Python的交互模式
直接在终端中运行.py文件,就相当于直接运行程序。(启动了Python解释器,然后一次性把.py文件的源代码给执行了。)


2016新书,和另一个Learning Python(最新第5版)不是同一个,书面相同 Paperback: 140 pages Publisher: Packt Publishing - ebooks Account (January 1, 2016) Language: English ISBN-10: 178528424X ISBN-13: 978-1785284243 Key Features Find out how to interact with Jenkins from within Eclipse, NetBeans, and IntelliJ IDEA Develop custom solutions that act upon Jenkins information in real time A step-by-step, practical guide to help you learn about extension points in existing plugins and how to build your own plugin Book Description Jenkins CI is the leading open source continuous integration server. It is written in Java and has a wealth of plugins to support the building and testing of virtually any project. Jenkins supports multiple Software Configuration Management tools such as Git, Subversion, and Mercurial. This book explores and explains the many extension points and customizations that Jenkins offers its users, and teaches you how to develop your own Jenkins extensions and plugins. First, you will learn how to adapt Jenkins and leverage its abilities to empower DevOps, Continuous Integration, Continuous Deployment, and Agile projects. Next, you will find out how to reduce the cost of modern software development, increase the quality of deliveries, and thereby reduce the time to market. We will also teach you how to create your own custom plugins using Extension points. Finally, we will show you how to combine everything you learned over the course of the book into one real-world scenario.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值