日本综合一区二区|亚洲中文天堂综合|日韩欧美自拍一区|男女精品天堂一区|欧美自拍第6页亚洲成人精品一区|亚洲黄色天堂一区二区成人|超碰91偷拍第一页|日韩av夜夜嗨中文字幕|久久蜜综合视频官网|精美人妻一区二区三区

RELATEED CONSULTING
相關(guān)咨詢
選擇下列產(chǎn)品馬上在線溝通
服務(wù)時(shí)間:8:30-17:00
你可能遇到了下面的問題
關(guān)閉右側(cè)工具欄

新聞中心

這里有您想知道的互聯(lián)網(wǎng)營(yíng)銷解決方案
創(chuàng)新互聯(lián)Python教程:如何調(diào)用python中的shell腳本?

相信大家對(duì)于這塊了解應(yīng)該挺豐富了吧,小編早幾期一直給大家教大家相關(guān)的內(nèi)容,不知道現(xiàn)在在給大家提及,腦子里會(huì)不會(huì)有些許印象呢?或者,大家可不可以給小編完成這次我們文章的問題呢?最起碼大家心里應(yīng)該知道怎么去調(diào)用一些腳本了吧,那大家根據(jù)自己的想像,在看下下文小編給的內(nèi)容,結(jié)合起來,優(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)用方式一不一樣呢?大概都能看出來關(guān)于python調(diào)用腳本時(shí)候,大致都是這樣子的吧,那大家如果遇到類似問題,可以舉一反三學(xué)習(xí)哦~


當(dāng)前標(biāo)題:創(chuàng)新互聯(lián)Python教程:如何調(diào)用python中的shell腳本?
鏈接URL:http://www.dlmjj.cn/article/dhgcdcd.html