初始python

一、python简介

1.Python的历史
  • 1989年圣诞节

Guido von Rossum开始写Python语言的编译器

  • 1991年2月

第一个Python编译器(同时也是解释器)诞生,它是用c语言实现的,可以调用c语言的库函数(Java- - - Jython;c# - - -IronPython ;后面PyPy,Brython,Pyston)

在最早的版本中,Python就已经提供对类、函数、异常处理等构造块的支持、同时提供了列表和字典等核心数据类型、同时支持以模块为基础的扩展系统。

  • 1994年1月

Python 1.0正式发布

  • 2000年10月16日

Python 2.0发布,增加了实现完整的垃圾回收,提供了对Unicode的支持。

同时,Python的整个开发过程更加透明。

  • 2008年12月3日

Python 3.0发布,它并完全兼容之前的Python代码,所以后来Python 3.x的很多特性也被移植到Python 2.6/2.7版本中

  • 目前

使用的Python 3.7.x版本 ,2018年发布

Python版本号的含义:
A.B.C
A表示大版本号,一般当整体重写,或出现不向后兼容的改变时,增加A
B表示功能更新,出现新功能是增加B
C表示小的改动(如修复了某个Bug),只要有修改就增加C
2.Python的优缺点

优点:

  • 简单和明确,做一件事只有一种方法
  • 学习曲线低,跟其他很多语言相比,Python更容易上手
  • 开放源代码,拥有强大的社区和生态圈
  • 解释性语言,天生具有平台可移植性
  • 支持两种主流的编程范式(面对对象编程和函数式编程)都提供了支持
  • 可扩展性和可嵌入性,可以调用C/C++代码,也可以在C/C++中调用Python
  • 代码规范程度高,可读性强,适合有代码洁癖和强迫症的人群

缺点:

  • 执行效率低,因此计算密集型任务可以由C/C++编写
  • 代码无法加密,
  • 在开发时可以选择的框架太多
3.Python的应用领域
  • 云基础设施
  • DevOps
  • 网络爬虫开发
  • 数据分析挖掘
  • 机器学习

二、搭建编程环境

1.pycharm的下载

直接baidu搜pycharm

jetbrains.com/pycharm/download

2.python

去python官网下载

三、从终端运行Python程序

1.确认Python的版本

打开cmd,输入

python --version

在这里插入图片描述

也可以打开IDLE,输入

improt sys
print(sys.version_info)
print(sys.version)

在这里插入图片描述

2.编写Python源代码

可以用文本编辑器工具(sublime、Atom、TwxtMate、VSCode)编写Python源代码并将其命名为以.py结尾的文件。

在这里插入图片描述

在里面输入

print('hello world!')
3.运行程序

用cmd,切换到源代码所在目录,

python test.py

在这里插入图片描述

四、代码中的注释

1.单行注释
以#和空格开头的部分
2.多行注释
上那个引号开头,三个引号结尾

在这里插入图片描述

五、其他工具介绍

1.IDLE

这个自带的,在搜索栏输入IDLE找

2.IPython

在cmd输入,安装ipython

pip install ipython

或者

python -m pip install ipython

安装成功后在cmd 输入

ipython

进入界面

在这里插入图片描述

也可以安装Jupyter并运行名位notebook的程序在浏览器窗口中进行交互式代码编写操作

pip install jupyter
jupyter notebook

不行就用这个

pip install --upgrade jupyter

六、练习

1.用ipython 输入
import this
Beautiful is better than ugly.
Explicit is better than implicit.
Simple is better than complex.
Complex is better than complicated.
Flat is better than nested.
Sparse is better than dense.
Readability counts.
Special cases aren't special enough to break the rules.
Although practicality beats purity.
Errors should never pass silently.
Unless explicitly silenced.
In the face of ambiguity, refuse the temptation to guess.
There should be one-- and preferably only one --obvious way to do it.
Although that way may not be obvious at first unless you're Dutch.
Now is better than never.
Although never is often better than *right* now.
If the implementation is hard to explain, it's a bad idea.
If the implementation is easy to explain, it may be a good idea.
Namespaces are one honking great idea -- let's do more of those!

在这里插入图片描述

2.pycharm也行
import turtle
turtle.pensize(4)
turtle.pencolor('red')
turtle.forward(100)
turtle.right(90)
turtle.forward(100)
turtle.right(90)
turtle.forward(100)
turtle.right(90)
turtle.forward(100)
turtle.mainloop()

在这里插入图片描述

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值