![](https://img-blog.csdnimg.cn/20201014180756738.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
Python
Hi Man
这个作者很懒,什么都没留下…
展开
-
Python之读取文件指定字符串
Python之读取文件指定字符串打开文件pmcdr,按行读取,取出以changeset:开头的行并保存到文本文件 out.txt 中import ref = open('out.txt','w')with open('pmcdr','rU') as file_object: for line in file_object.readlines(): g = re.search("changeset:*", line) if g: prin原创 2020-10-10 14:21:07 · 2667 阅读 · 1 评论 -
Python之获取命令行输入
code:#!/usr/bin/env python import argparse ...原创 2019-09-05 10:16:02 · 3869 阅读 · 0 评论 -
python之自动登录Telnet并执行command
code:#!/usr/bin/pythonimport telnetlibimport sysimport timeimport loggingclass TelnetClient(): def __int__(self,): self.tn = telnetlib.Telnet() def login_host(self, host_ip, u...原创 2019-09-06 13:09:50 · 1358 阅读 · 0 评论 -
Python之字符串操作
1. 字符串替换string.replace(str1, str2, num=string.count(str1))把 string 中的 str1 替换成 str2,如果 num 指定,则替换不超过 num 次.var1 = 'hello world'var2 = var1.replace('world', 'raind', 1)print var1print var22. s...原创 2019-09-06 13:39:28 · 125 阅读 · 0 评论 -
python 之文件目录操作
code:print("hello")import globfor name in glob.glob(r'./*'): print (name)note:windows下测试好使,可以打印出当前目录的所有文件。知识点:字符串前面加个 r: 表示 非转译字符串:与普通字符相比,其他相对特殊的字符,其中可能包含转义字符,即那些,反斜杠加上对应字母,表示对应的特殊含义的,比如最常...原创 2019-09-09 22:40:20 · 138 阅读 · 0 评论 -
python之执行 shell命令
subprocess 模块这个模块是用来代替几个老的模块:os.systemos.spawn*os.popen*popen2.*commands.*实例:#!/usr/bin/python ...原创 2019-09-10 22:37:50 · 133 阅读 · 0 评论