Python&PyCharm

在这里插入图片描述

一:python语言概述

1.python语言

1.1.python语言的基本概念

  • Python 是一种极少数能兼具 简单 与 功能强大 的编程语言 ,它专注于如何解决问题,而非拘泥于语法与结构.
  • 官方介绍如下:
    Python 是一款易于学习功能强大的编程语言。 它具有高效率的数据结构,能够简单又有效地实现面向对象编程。Python 简洁的语法与动态输入之特性,加之其解释性语言的本质,使得它成为一种在多种领域与绝大多数平台都能进行脚本编写与应用快速开发工作的理想语言
  • python是由吉多·范罗苏姆(Guido van Rossum)创造出来的,python采用于作者喜欢的电视节目《蒙提·派森的飞行马戏团——Monty Python’s Flying Circus》Python。

2.python的特点

  • 简单易学
  • 自由开源
  • 跨平台性
  • 可嵌入性
  • 丰富的库
  • 可移植性
  • 面向对象

二:python的发展及应用

1.python的发展

在这里插入图片描述

2.运用python的企业

在这里插入图片描述

3.python的发展方向

  • Web开发
  • 运维自动化
  • 测试自动化
  • 软件开发
  • 网络爬虫
  • 数据分析
  • 人工智能
  • 科学计算

三:python之禅

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!

  • 美胜于丑陋(Python 以编写优美的代码为目标)
    明了胜于晦涩(优美的代码应当是明了的,命名规范,风格相似)
    简洁胜于复杂(优美的代码应当是简洁的,不要有复杂的内部实现)
    复杂胜于凌乱(如果复杂不可避免,那代码间也不能有难懂的关系,要保持接口简洁)
    扁平胜于嵌套(优美的代码应当是扁平的,不能有太多的嵌套)
    间隔胜于紧凑(优美的代码有适当的间隔,不要奢望一行代码解决问题)
    可读性很重要(优美的代码是可读的)
    即便假借特例的实用性之名,也不可违背这些规则(这些规则至高无上)
    不要包容所有错误,除非你确定需要这样做(精准地捕获异常,不写 except:pass 风格的代码)
    当存在多种可能,不要尝试去猜测而是尽量找一种,最好是唯一一种明显的解决方案(如果不确定,就用穷举法)
    虽然这并不容易,因为你不是 Python 之父(这里的 Dutch 是指 Guido )
    做也许好过不做,但不假思索就动手还不如不做(动手之前要细思量)
    如果你无法向人描述你的方案,那肯定不是一个好方案;反之亦然(方案测评标准)
    命名空间是一种绝妙的理念,我们应当多加利用(倡导与号召)
  • win+R—>cmd—>python---->import this.在这里插入图片描述

四:python环境搭建

1.环境搭建

  • 环境搭建就是安装python解释器
  • 解释器的分类:
    CPython(官方我们用的就是这个版本) 用c 语言编写的Python解释器
    PyPy 用Python语言编写的Python解释器
    JPython 用Java编写的Python解释器
  • 在百度输入python---->找到官网在这里插入图片描述
  • 在这里插入图片描述
  • 不要下载在这里插入图片描述
    在这里插入图片描述
    在这里插入图片描述
    在这里插入图片描述
    在这里插入图片描述
    在这里插入图片描述
  • 在cmd中输入python,如图安装成功
    在这里插入图片描述

2.python的交互模式

在这里插入图片描述

• win键 + R --> CMD --> 回车 --> 输入Python
• 命令行结构
• Python 3. 6. 5 … —> 版本
• Type “help”,“copyright”…—> 版权声明
• >>> —> 命令提示符 (在后面可以直接输入指令)

3.pip

3.1.pip使用

  • 在命令行下,输入pip,回车可以看到帮助说明:在这里插入图片描述

3.2.查看pip版本

  • pip+空格±V(大写)/±-version在这里插入图片描述

3.3.用pip安装

  • 普通安装
pip install requests  
  • 指定版本安装
pip install robotframework==2.8.7
  • 卸载已安装的库
pip uninstall requests
      pip install SomePackage==1.0.5       # 指定版本
      pip install 'SomePackage>=1.0.6'     # 最小版本
  • 列出已安装的库
    ···
    pip list
    ···
  • 显示安装包信息
    ···
    pip show package
    ···
  • 将已安装的库列表保存到文本文件中
    ···
    pip freeze > +路径+文本文件名
    ···
  • 换源安装
    豆瓣 :http://pypi.douban.com/simple/
    阿里 :http://mirrors.aliyun.com/pypi/simple/
    中国科学技术大学:http://pypi.mirrors.ustc.edu.cn/simple
    清华:https://pypi.tuna.tsinghua.edu.cn/simple
    例如:pip install SomePackage -i https://pypi.douban.com/simple

4.python程序

  • 最好用高级开发工具:PyCharm。

五:PyCharm的安装和配置

1.安装

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

2.配置

  • python和PyCharm(PC)之间无任何关系,需要对PC进行配置,将二者连接起来。
  • 在这里插入图片描述
  • 点击1在这里插入图片描述
    右键demo1
    在这里插入图片描述
    自定义命名在这里插入图片描述
    在这里插入图片描述
    上图操作见下
    在这里插入图片描述

在这里插入图片描述

  • 点击2.之前
    先建立一个文件,之后open文件
    然后在这里插入图片描述
    在这里插入图片描述
    在这里插入图片描述
    • 1、主题修改 File–settings–apperance–theme
    • 2、代码字体修改 File–settings–Editor-Font
    • 3、关闭更新 File–settings—apperance—System Settings —Updates — Automatically check updates for 取消打钩
    • 4、快捷键修改 File–settings—apperance-- Keymap 选择自己习惯的快捷键方式
    • 5、自动导包 File–settings—apperance–General —Auto Import 打钩
    • 6、进制打开上次的工程 File–settings—apperance—System Settings —Reopen last project startup
    • 7、修改新建文件文件头 File–settings–Editor—Code Style — File and Code Templates — Python Script
    • #!/usr/bin/env python
    • # -- coding: utf-8 --
    • # @Time : ${DATE} ${TIME}
    • # @Author : Jerry
    • # @File : ${NAME}.py
    • # @Software: ${PRODUCT_NAME}
    • 8、修改字体编码 File–settings–Editor—Code Style — File Encoding — Project Encoding

猜你喜欢

转载自blog.csdn.net/jianyuanhaohao/article/details/113118549
今日推荐