我在服务器上的得到一些数据,然后用shell截取并整理,每3个分成一组。然后是我想把这若干组数据每组当作一组参数传入一个python的函数,应该怎样做?
欢迎选择我的课程,让我们一起见证您的进步~~
You can use the argparse module:
# coding: utf-8 import argparse def bar(*args, **kwargs): print 'command parameter:', args, kwargs if __name__ == '__main__': parser = argparse.ArgumentParser() parser.add_argument("port", help="listen to the server port.", type=int) args = parser.parse_args() parser = argparse.ArgumentParser() bar(args.port)
If you use bash to process data, you can also use python to receive and process it. This way you don’t have to pass the data to python through bash, and python is also very simple.
I feel like you said this amount is huge? Consider pipe or save it as a file and read it with Python
You can use the argparse module:
If you use bash to process data, you can also use python to receive and process it. This way you don’t have to pass the data to python through bash, and python is also very simple.
I feel like you said this amount is huge? Consider pipe or save it as a file and read it with Python