python自动化更贴近运维自动化

Python自动化–1.Python环境安装-linux

Python自动化–2.Python变量

Python自动化–3.Python数据类型

Python自动化–4. python类型转换

Python自动化–5. if判断语句

Python自动化–6. 写一个python程序

Python自动化–7. 函数的定义和调用


前言–Python于我们有何益处

首先是Python可以说是Linux运维工程师首选的编程语言,而且Python在自动化运维方面深入人心,受到了大家的追捧和较为广泛的应用。

1. python可以编写各种Devops工具,对开源软件进行二次开发。

2. python可以开发公司的内部办公系统、CRM、网站等。学会了自动化开发我们不仅仅可以做运维领域的自动化工作,也可以尝试去做纯开发的工作。

3. 通过学习python后,帮助评估和优化业务技术架构,从运维层面来讲,我们更多是从应用和服务层面去调整参数而进行服务的优化;然而,无论我们做多少集群、配置多高性能的服务器都不能使你的业务访问速度变快,那么就需要具备开发能力,从而帮助评估技术架构是否合理,该优化优化,该分布分布,该异步时异步从架构的层面解决问题,也是一个架构师的必经之路。

4. 成为一名全栈工程师,Python是一种全栈式综合语言,可以用来做自动化运维/开发/测试、后端、爬虫开发、前端、游戏、数据分析、机器学习等,我们也完全可以通过python的使用而成为全栈工程师。

1. Python环境安装-linux

在这里以CentOS 7版本为例:

如我的系统版本

1.1 开始环境安装

yum groupinstall "Development Tools"
#安装开发者工具包yum -y install zlib-devel bzip2-devel openssl-devel sqlite-devel readline-devel libffi-devel
#安装相关依赖软件
yum grouplistwget https://www.python.org/ftp/python/3.7.6/Python-3.7.6.tar.xz
tar -xf Python-3.7.6.tar.xz
cd Python-3.7.6
vim Modules/Setup.dist SSL=/usr/local/ssl
_ssl _ssl.c \-DUSE_SSL -I$(SSL)/include -I$(SSL)/include/openssl \-L$(SSL)/lib -lssl -lcrypto./configure --enable-sharedmake -j 2 && make install
#下载-解压-配置-编译安装

1.2. 环境变量配置

cmd1='export LD_LIBRARY_PATH='
cmd2='$LD_LIBRARY_PATH:/usr/local/lib'
file="/etc/profile.d/python3_lib.sh"${}
echo "${cmd1}${cmd2}" >$file
#配置环境变量
path="/usr/local/lib"
file2="/etc/ld.so.conf.d/python3.conf"
echo ${path} > $file2
#配置环境变量vim /etc/profile.d/python3_lib.sh export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/libldconfig
source /etc/profile
python3 -V
#查看版本

1.3. pip配置

python3 -V
pip3 -V
#查看python3  pip3版本mkdir /root/.pip
cd /root/.pip
#创建pip配置文件目录echo '[global]' >> ~/.pip/pip.conf
c1="index-url=https://"
c2="mirrors.aliyun.com/pypi/simple"
echo "${c1}${c2}" >> /root/.pip/pip.conf
#配置pip3国内阿里云源pip3 install ipython
#安装iPython工具
pip3  install --upgrade pip
#更新pip
ipython
#工具

1.4. 使用ipython测试

ipython
Python 3.7.6 (default, Mar 21 2022, 21:41:11)
Type 'copyright', 'credits' or 'license' for more information
IPython 7.32.0 -- An enhanced Interactive Python. Type '?' for help.In [1]: s = 'hello python'In [2]: s.upper()
Out[2]: 'HELLO PYTHON'
#调用方法--大写In [3]: ??open
#看源码(如open为内置变量)
Signature:
open(file,mode='r',buffering=-1,encoding=None,errors=None,newline=None,closefd=True,opener=None,
) #可以调用变量
Docstring:
Open file and return a stream.  Raise OSError upon failure.file is either a text or byte string giving the name (and the path
if the file isn't in the current working directory) of the file to
be opened or an integer file descriptor of the file to be
wrapped. (If a file descriptor is given, it is closed when the
returned I/O object is closed, unless closefd is set to False.)mode is an optional string that specifies the mode in which the file
is opened. It defaults to 'r' which means open for reading in text
mode.  Other common values are 'w' for writing (truncating the file if
it already exists), 'x' for creating and writing to a new file, and
'a' for appending (which on some Unix systems, means that all writes
append to the end of the file regardless of the current seek position).
In text mode, if encoding is not specified the encoding used is platformq #返回In [4]: !vim python.py
#调用shell命令In [5]: %run python.py
hello vc
字符串需加引号
#执行Python脚本#ipython测试用

Python自动化--1.Python环境安装-linux相关推荐

  1. Selenium2+python自动化1(环境安装)

    前言 目前selenium版本已经升级到3.0了,网上的大部分教程是基于2.0写的,所以在学习前先要弄清楚版本号,这点非常重要.本系列依然以selenium2为基础,目前selenium3坑比较多,暂 ...

  2. 1.python学习工具与环境安装

    python学习工具与环境安装 因为上传的时候图片出现了些问题,详细的图片可以下载博客内PNG或者PDF版图片版进行观看 无python环境 有python环境 未使用过anaconda管理pytho ...

  3. python3.7.2安装包_Win10下python 2.7与python 3.7双环境安装教程图解

    Win10下python 2.7与python 3.7双环境安装教程,具体内容如下所示: 1.python软件下载网址: https://www.python.org/downloads/window ...

  4. Python自动化--3.Python数据类型

    python自动化更贴近运维自动化 Python自动化–1.Python环境安装-linux Python自动化–2.Python变量 Python自动化–3.Python数据类型 Python自动化 ...

  5. Appium+python自动化8-Appium Python API

    Appium+python自动化8-Appium Python API 前言: Appium Python API全集,不知道哪个大神整理的,这里贴出来分享给大家. 1.contexts contex ...

  6. Python基础概念_1_环境安装

    环境安装 2 环境安装 在开始Python学习前,我们先要搭建开发环境,正所谓巧妇难为无米之炊.那么什么是开发环境呢?通俗的理解假设我们要做饭,那么得有锅.油.燃气.菜这些基础工具和素材,有了它们我们 ...

  7. 初始----python数字图像处理--:环境安装与配置

    一提到数字图像处理编程,可能大多数人就会想到matlab,但matlab也有自身的缺点: 1.不开源,价格贵 2.软件容量大.一般3G以上,高版本甚至达5G以上. 3.只能做研究,不易转化成软件. 因 ...

  8. python编辑配置_Python环境安装及编辑器配置(一)

    在2018年决定写一些关于Python的文章,其实写博客这件事在2016年就有了,但是因为个人的一些原因一直被耽搁.所以2018年的目标之一就是写多一点的博客,不管是是生活还是工作.好吧,废话不多说, ...

  9. python 自动化-利用Python语言实现实验室自动化

    作为一名系统和应用工程师,得益于自动化仪器和软件,我已经节省了不计其数的日日夜夜;例如LabVIEW,这是一款系统设计平台和开发环境,支持可视化编程语言.LabVIEW支持用户利用友好的图形用户界面( ...

最新文章

  1. BeanUtils使用
  2. python api开发用什么框架_python+requests接口自动化框架
  3. (转)博弈问题与SG函数
  4. spark Rdd 操作transformaction和action等
  5. Geary 0.13.0 发布,GNOME 3 Email 客户端应用
  6. AnimalTFDB 3.0 | 动物转录因子注释和预测的综合资源库
  7. The Reactive Manifesto(响应式宣言)
  8. python合并大量ts文件_python合并ts视频
  9. Windows XP 启动NetMeeting
  10. iOS 实现长屏截图,scrollview,tableview截图
  11. 面试求职-你们想知道的腾讯面经
  12. 数据结构学习(考研408)
  13. Java第十五篇:详解一元二次方程
  14. python中xml Excel解析编码小结
  15. 那些让人极度舒适的软件,盘点一下数据人必备的黑科技
  16. JavaScript专题(二):深入理解iframe
  17. 用Android Studio设计的一个简单的闹钟APP
  18. 使用HTML5 Canvas实现马赛克拼图
  19. Java-单元测试(JUnit框架、常用注解)
  20. 猫鸡米问题java_人猫鸡米渡河问题的数学模型

热门文章

  1. access 套用表格_Word表格编辑技巧:在Word中使用Access的数据-word技巧-电脑技巧收藏家...
  2. C语言编程之计算平均成绩
  3. 公共经济学(开卷)期末复习题
  4. 使用@JsonFormat注解 后端往前端页面展示日期为英文问题 (例如:Thu Dec 09 00:00:00 CST 2021)
  5. 如何给微信公众号增加留言功能?
  6. 基于JAVA网上体育用品销售系统计算机毕业设计源码+系统+mysql数据库+lw文档+部署
  7. html页面显示代码插件,jQuery – 高亮动态显示页面HTML代码插件
  8. php - 解决百万级全站用户消息推送问题
  9. [Linux] Bash中大括号和小括号的使用
  10. 阿里面试——机器学习/算法面试经验案例集合