新聞中心
相信大家對(duì)于這塊了解應(yīng)該挺豐富了吧,小編早幾期一直給大家教大家相關(guān)的內(nèi)容,不知道現(xiàn)在在給大家提及,腦子里會(huì)不會(huì)有些許印象呢?或者,大家可不可以給小編完成這次我們文章的問題呢?最起碼大家心里應(yīng)該知道怎么去調(diào)用一些腳本了吧,那大家根據(jù)自己的想像,在看下下文小編給的內(nèi)容,結(jié)合起來(lái),優(yōu)化下吧~

站在用戶的角度思考問題,與客戶深入溝通,找到新城網(wǎng)站設(shè)計(jì)與新城網(wǎng)站推廣的解決方案,憑借多年的經(jīng)驗(yàn),讓設(shè)計(jì)與互聯(lián)網(wǎng)技術(shù)結(jié)合,創(chuàng)造個(gè)性化、用戶體驗(yàn)好的作品,建站類型包括:成都網(wǎng)站制作、成都網(wǎng)站設(shè)計(jì)、外貿(mào)營(yíng)銷網(wǎng)站建設(shè)、企業(yè)官網(wǎng)、英文網(wǎng)站、手機(jī)端網(wǎng)站、網(wǎng)站推廣、空間域名、網(wǎng)頁(yè)空間、企業(yè)郵箱。業(yè)務(wù)覆蓋新城地區(qū)。
1. python調(diào)用shell方法os.system()
#!/usr/local/bin/python3.7
import time
import os
count = 0
n = os.system('sh b.sh')
while True:
count = count + 1
if count == 8:
print('this count is:',count)
break
else:
time.sleep(1)
print('this count is:',count)
print('Good Bye')
shell腳本如下:
#!/bin/sh echo "hello world"
運(yùn)行結(jié)果:
[python@master2 while]$ python a.py hello world this count is: 1 this count is: 2 this count is: 3 this count is: 4 this count is: 5 this count is: 6 this count is: 7 this count is: 8 Good Bye
2. python調(diào)用shell方法os.popen()
#!/usr/local/bin/python3.7
import time
import os
count = 0
n = os.system('sh b.sh')
while True:
count = count + 1
if count == 8:
print('this count is:',count)
break
else:
time.sleep(1)
print('this count is:',count)
print('Good Bye')
運(yùn)行結(jié)果:
[python@master2 while]$ python a.py['hello world\n'] this count is: 1 this count is: 2 this count is: 3 this count is: 4 this count is: 5 this count is: 6 this count is: 7 this count is: 8 Good Bye
好啦,大家看下是否跟平常調(diào)用方式一不一樣呢?大概都能看出來(lái)關(guān)于python調(diào)用腳本時(shí)候,大致都是這樣子的吧,那大家如果遇到類似問題,可以舉一反三學(xué)習(xí)哦~
新聞名稱:創(chuàng)新互聯(lián)Python教程:如何調(diào)用python中的shell腳本?
地址分享:http://fisionsoft.com.cn/article/dhgcdcd.html


咨詢
建站咨詢
