![](https://img-blog.csdnimg.cn/20201014180756738.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
Python
weixin_45833713
这个作者很懒,什么都没留下…
展开
-
python-批量移动文件
#!/usr/local/bin/python3‘批量移动前缀为"haigui"的文件到/company目录下’import osimport shutilimport redef move_file(src_path, dest_path, regexp) :ll_gen = os.walk(src_path)for ll_tuple in ll_gen :if ll_tuple...原创 2020-03-19 17:21:03 · 219 阅读 · 0 评论 -
python3——日志切割查看
#!/usr/local/bin/python3import timeimport sys# print(time.time())# print(type(time.ctime()))# print(time.localtime())# t = time.localtime()# print(t)# time.sleep(1)def cut_log(s1,s2) : ...原创 2020-02-15 23:01:06 · 183 阅读 · 0 评论 -
python和shell:对比两个文件不同的行
#!/bin/bash# 对比两个文件处不同的模板a=$(awk -F: '{print $7}' $1 | sort |uniq )for line1 in $a :do for line2 in $2: do if [ ${line1} != ${line2} ];then echo ${line1} >> newlin...原创 2020-02-14 21:54:17 · 193 阅读 · 0 评论 -
python---非交互式创建用户
#!/usr/local/bin/python3'非交互获取用户名,并生成随机密码,并将信息写入到文件中'import sysimport subprocessimport rand_char3# 创建可用用户和密码,并写入到指定文件中def cusr_wfile(u_name,passwd,f_name): # 判断用户名是否可用 result = su...原创 2020-02-12 22:30:09 · 332 阅读 · 0 评论 -
Python——遍历文本文件与非文本文件
#!/usr/loca/bin/python3'通过位置变量读取文本文件、非文本文件'import sysdef s_tf(f_name) : f_obj = open(f_name) for line in f_obj : print(line,end='') f_obj.close()def s_nft(f_name) : f_ob...原创 2020-02-12 22:09:38 · 276 阅读 · 0 评论 -
Python的生成用户练习案例
#!/usr/local/bin/python3'Python的生成用户练习案例'import stringimport subprocessimport randomimport os# 交互获取用户名,返回可用用户名def get_un(): while 1 : u_name = input('用户名') result = subpro...原创 2020-02-12 22:08:49 · 112 阅读 · 0 评论 -
Python——生成随机密码
案例:生成随机密码#!/usr/local/bin/python3#-*- coding: utf-8 -*-from random import choicefrom string import ascii_letters , digitsdef mk_rpass(n=8): # 定义字符集 zifuji = ascii_letters + digits #...原创 2020-02-12 09:47:03 · 206 阅读 · 0 评论 -
Python——二层循环嵌套3个小练习
练习1:3*3的hello#!/usr/loca/bin/python3#cording:utf-8#打印3*3的hellofor i in range(3): for j in range(3): print('hello',end=' ') # 后print函数最后默认加回车,可以用end修改 print()练习2: 二层嵌套,递增打...原创 2020-02-11 10:01:00 · 512 阅读 · 0 评论