There are two files, one is
File 1:sync_shop_source_bimer.sh
File 2:sync_shop_source_bimer.py
Call sync_shop_source_bimer.py in sync_shop_source_bimer.sh
Files generated in file 1 are passed to file 2
What's in file 1
shop_flow_output= "/tmp/shop_flow_source"
shop_gmv_output= "/tmp/shop_gmv_source"
Yesday= ' date-d " -1day" + "%y-%m-%d" '
/usr/local/bin/python sync_shop_source_bimer.py--date $yesday--flow_file $shop _flow_output--deal_file $shop _gmv_ Output
Receive files in file 2
Import datetime
Import Argparse
Def Get_args ():
Parser = Argparse. Argumentparser ()
Parser.add_argument ('-d ', '--date ', help= ' date to stat, format:2015-03-01 ', default = Datetime.datetime.now (). strftime ("%y-%m-%d"))
Parser.add_argument ('-f ', '--flow_file ', help= ' flow file ')
Parser.add_argument ('-G ', '--deal_file ', help= ' GMV file ')
args = Parser.parse_args ()
return args
def main ():
args = Get_args ()
#打印接收参数
Print dt = Datetime.datetime.strptime (args.date, "%y-%m-%d")
Print Flow_shop = Args.flow_file
Print Gmv_shop = Args.deal_file
Use of the Argparse module in Python