摘要: 装饰器使用装饰器可以在不改动原有函数和调用方式时给函数附加功能装饰器是由高阶函数+嵌套函数+高阶函数组成的装饰器原则:1.不修改被装饰对象的源代码2.不修改被装饰对象的调用方式 调用方式: 进一步使用方法: 阅读全文
posted @ 2017-11-02 23:00 uyahs 阅读(102) 评论(0) 推荐(0) 编辑
摘要: 函数的定义: def 函数名: def test():函数的调用: test()接收函数返回值: result = test()函数的参数 在函数中使用return 来返回一个值 返回值可以使数字、字符串、列表、元组、 字典等。 如果没有返回值则返回none 可以有多个返回值。 返回值个数 = 0时 阅读全文
posted @ 2017-10-24 02:14 uyahs 阅读(117) 评论(0) 推荐(0) 编辑
摘要: 使用python对文件内容增删改查 首先要使用方法open打开需要操作的文件。 open( 文件路径 , 打开模式 , 编码方式 ) 第一个参数填写要打开的文件路径和文件名,第二个参数告诉函数以什么模式来打开文件(比如 只读,只写,读写等,最后一个参数填写需要用什么编码格式来读取内容(encodin 阅读全文
posted @ 2017-10-23 10:44 uyahs 阅读(163) 评论(0) 推荐(0) 编辑
摘要: #常用的字符串操作#somestring.capitalize() 首字母大写,不需要参数#somestring.lower() 将字母转换为小写#somestring.upper() 将字母转换为大写#somestring.count() 统计参数出现的次数#somestring.find() 查 阅读全文
posted @ 2017-10-17 23:50 uyahs 阅读(170) 评论(0) 推荐(0) 编辑
摘要: 数据运算 + - */ 加减乘除 %取余 //整除 **幂比较运算 ==等于 !=不等于 <>不等于 <=小于等于 >=大于等于 赋值运算 += 加法赋值运算 -= 减法赋值运算 *= 乘法赋值运算 /= 除法赋值运算 %= 取余赋值运算 //= 取整除赋值运算 **= 幂赋值运算 逻辑运算 and 阅读全文
posted @ 2017-10-16 23:21 uyahs 阅读(154) 评论(0) 推荐(0) 编辑
摘要: 列表学习 定义列表 name = [1,2,3,4,5] 增 append() 在列表末尾位置追加 insert(0) 在指定位置增加 name.extend(name2) 扩展列表,将列表name2扩展到列表name中 删 name.remove("value") 移除列表指定的值 del nam 阅读全文
posted @ 2017-10-16 23:19 uyahs 阅读(135) 评论(0) 推荐(0) 编辑
摘要: #!/bin/bashselect banben in nginx-1.6.3 nginx-1.7.3 nginx-1.8.1 nginx-1.9.9do if [[ -n $banben ]] ;then breakfidonepath_nginx="http://nginx.org/downlo 阅读全文
posted @ 2017-10-15 11:50 uyahs 阅读(939) 评论(0) 推荐(1) 编辑
摘要: #这个脚本开始前会自动删除range文件#IP段与IP段之间可以同行但是必须用分号或空格隔开#可以有空行 #!/bin/basheth_file=(`ls /etc/sysconfig/network-scripts | grep "ifcfg-*"`)select eths in "${eth_f 阅读全文
posted @ 2017-10-15 11:49 uyahs 阅读(759) 评论(0) 推荐(1) 编辑
摘要: #!/bin/bashexport deviceecho "请输入网络设备名:"devices="`ifconfig -s|sed '1d'|awk '{print($1)}'`"select device in $devices;doif [ -n "$device" ];thenbreakfid 阅读全文
posted @ 2017-10-15 11:49 uyahs 阅读(643) 评论(0) 推荐(0) 编辑
摘要: 1.安装Development Tools yum groupinstall -y 'development tools'2安装SSL、bz2、zlib来为Python的安装做好准备工作 yum install -y zlib-devel bzip2-devel openssl-devel xz-l 阅读全文
posted @ 2017-10-15 11:48 uyahs 阅读(728) 评论(0) 推荐(0) 编辑