#!/usr/bin/env python
#-*- coding: UTF- -*-
from __future__ import print_function
import time,os,sys,re,subprocess,commands,itertools,readline dt=time.localtime()
ft=" %Y-%m-%d %H:%M:%S %p %A"
date=time.strftime(ft,dt)
print(" 当前系统时间为:\n",date) #---------------------------------------------------------------------------------
#f0 = open('/etc/ssh/sshd_config','r')
#f1 = f0.readline()
#def get_number():
#sshd_config = "/etc/ssh/sshd_config"
#with open(sshd_config,'r') as f:
#for line in f.readlines():
#try:
#if'Port' in line:
#strlist = line.split('Port ')
#for sshdport in strlist[:]:
#print(sshdport)
#except:
#print('获取失败')
#if __name__ == '__main__':
#get_number()
#---------------------------------------------------------------------------------
#f = open('/etc/ssh/sshd_config','r')
#lines = f.readlines()
#for line in lines:
#if "Port " in line:
#print(line) #[root@localhost ~]# python .py
#当前系统时间为:
#-- :: PM Thursday
#Port
#--------------------------------------------------------------------------------- #yum install -y python python-devel #
#Port
#AddressFamily any #with open('/etc/ssh/sshd_config') as infile, open('/root/1.txt', 'w') as outfile:
#copy = False
#for line in infile:
#if line.strip() == "#":
#copy = True
#elif line.strip() == "#AddressFamily any":
#copy = False
#elif copy:
#outfile.write(line)
#[root@localhost ~]# cat .txt
#Port #---------------------------------------------------------------------------------
#pathfile = raw_input('文件绝对路径:')
#keyname = raw_input('查找内容:') #FoundFlag = False
#f00 = open(pathfile)
#f01 = f00.readline()
#while f01:
#if f01.find(keyname) == 0:
#FoundFlag = True
#print("---------------------------------------------------------------------------------")
#print(" 所在行: " + f01, end='')
#print("---------------------------------------------------------------------------------")
#break
#else:
#f01 = f00.readline()
#f00.close()
#if FoundFlag == False:
#print("获取失败.....!")
#raw_input() # 从下标0开始,查找在字符串里第一个出现的子串,返回结果: #[root@localhost ~]# python .py
#文件绝对路径:/etc/ssh/sshd_config
#查找内容:#Port
#---------------------------------------------------------------------------------
#所在行: #Port
#--------------------------------------------------------------------------------- #[root@localhost ~]# python .py
#文件绝对路径:/etc/ssh/sshd_config
#查找内容:
#获取失败.....!
#Traceback (most recent call last):
#File "1.py", line , in <module>
#raw_input()
#KeyboardInterrupt
#[root@localhost ~]# python .py
#文件绝对路径:/etc/ssh/sshd_config
#查找内容:Port
#获取失败.....!
#find 模块查询只能从左到右
#---------------------------------------------------------------------------------

最新文章

  1. JSon解析
  2. Entity Framework EF6使用 MySql创建数据库异常解决办法
  3. Photo Shop 修改、维护
  4. sql行列转换
  5. pygame系列_百度随心听_完美的UI设计
  6. [原创] zabbix学习之旅二:yum安装
  7. FWT 学习总结
  8. 多次绑定click及ajax提交常用方法
  9. JavaSE学习总结第10天_面向对象5
  10. jQuery --- 第四期 (jQuery动效)
  11. Python 3中bytes/string的区别
  12. [转]简单科普私钥、地址、助记词、Keystore的区别
  13. 解析 STM32 的库函数
  14. IIS 7安装ModSecurity实现WAF功能
  15. C/C++---printf/cout 从右至左压栈顺序实例详解
  16. 中小团队基于Docker的devops实践
  17. UVA 1203 - Argus(优先队列)
  18. OGNL是Object-Graph Navigation Language的缩写,它是一种功能强大的表达式语言
  19. Java进行http请求工具类代码(支持https)
  20. hibernate 关联关系

热门文章

  1. Scala语法03 - 函数
  2. mysql锁表机制分析
  3. node 笔记整理
  4. 学校或公司转ISP -boardband (上网公司)注意事项记录
  5. VMware workstation安装Windows Server 2012 R2步骤详解(附下载链接)
  6. 使用checked和unchecked来对整数溢出进行检测和忽略
  7. 大于2T的硬盘怎么分区
  8. 【VS开发】学习VS2010 ------ 多种类型的视图集合CTabView
  9. spark 1.6.0 安装与配置(spark1.6.0、Ubuntu14.04、hadoop2.6.0、scala2.10.6、jdk1.7)
  10. 实习第一个月总结(const关键字、条件编译、volatile关键字、#和##的作用、函数指针)