2017-06-27 173 views
-2

我想將這兩個GPIO命令實現到我的函數中,但它給我一個語法錯誤。但我不知道如何組織它。python在函數中執行命令行

elif message_text == HI and term.term_started == False: 
    fb.simple_msg(sender_id, gpio -g mode 17 out gpio -g write 17 1) 
+0

您沒有使用字符串引號。 – Leonard2

+0

將執行將打開GPIO 17 –

+0

將通過python執行的命令?我的意思是,python似乎不理解'gpio -g mode 17 out gpio -g write 17 1',這會導致語法錯誤。 – Leonard2

回答

0

我不知道這段代碼的功能,但這裏是我的猜測:

elif message_text == "HI" and term.term_started == False: 
    fb.simple_msg(sender_id, "gpio -g mode 17 out gpio -g write 17 1") 

在租賃如果像sender_id其他變量適當界定你不會得到語法錯誤。請注意,我改變

  • HI"HI"
  • gpio -g mode 17 out gpio -g write 17 1"gpio -g mode 17 out gpio -g write 17 1"