2017-08-16 29 views
0

我需要使用Python和Django使用.sh脚本回显消息。我在下面解释我的代码。如何使用.sh脚本使用Python和Django回显消息

def plantsave(request): 
    """ This function to save the reactor data . """ 

    if request.method == 'POST': 
     rname = request.POST.get('react')#Reactor1 ,Reactor2,Reactor3 
     if 'strt' in request.POST: 
      status = 1#Running 

     if 'shutbt' in request.POST: 
      status = 0#Stop 

     if 'susbtn' in request.POST: 
      status = 2#Suspend 

在这里,我要呼应消息像Reactor1 is running if the status=1 and Reactor2 is stop if status=0这样使用.sh script

+0

评论在python是通过'#'完成签署不''//我 –

+0

不明白的.sh你正在谈论的脚本。这是一个Python文件,而不是一个shell脚本。 –

回答

0

可毕竟if地址:

statuses = ['Stop', 'Running', 'Suspend'] 
str_status = '{rname}: {status}'.format(rname=rname, status=statuses[status]) 
print (str_status) 

希望它能帮助

+0

我需要总回声消息,其中'rname'的值是? – satya

+0

我编辑答案 –

+0

'str_status ='{rname}:{status}'.format(rname = rname,status = statuses [status])'使用'.sh脚本'运行? – satya