标签:must lse put read oca add one 通过 name
cat somefile.txt |python somescriot.py |sort
import sys
text = sys.stdin.read() #标准输入流
words = text.split()
print words
#用户互动
raw_input()
x = input(‘Enter the first number:‘)
y = input(‘Enter the second number:‘)
if len(sys.argv) == 2:
if sys.argv[1] == "check_hottopic":
check_hottopic()
if sys.argv[1] == "check_mongo":
check_mongo()
if sys.argv[1] == "check_menhu":
check_menhu()
if sys.argv[1] == "check_hotdoc":
check_hotdoc()
else:
print (".........the args must be [check_hottopic,check_mongo,check_menhu,check_hotdoc]. ")
else:
print (".........the arg have been more than one or no one found in args. ")
#!/bin/env python
import socket
import re
import sys
def check_server(address,port):
s = socket.socket()
print "Attempting to connect to %s on port %s" % (address,port)
try:
s.connect((address,port))
print "Connected to %s on port %s" % (address,port)
return True
except socket.error,e:
print "Connected to %s on port %s failed:%s" % (address,port,e)
return False
if __name__ == ‘__main__‘:
from optparse import OptionParser
parser = OptionParser()
#加入参数选项
parser.add_option("-a","--address",dest="address",default=‘localhost‘,help="ADDRESS for server",metavar="ADDRESS")
parser.add_option("-p", "--port",dest="port",type="int",default=80,help="PORT for server",metavar="PORT")
#解析
(options,args) = parser.parse_args()
print ‘options :%s,args:%s‘ % (options,args)
check = check_server(options.address,options.port)
print ‘check_server returned %s‘ % check
sys.exit(not check)
标签:must lse put read oca add one 通过 name
原文地址:https://www.cnblogs.com/zhaobowen/p/13567902.html