中文字幕第五页-中文字幕第页-中文字幕韩国-中文字幕最新-国产尤物二区三区在线观看-国产尤物福利视频一区二区

3種python調用其他腳本的方法,你還知道其他的方法嗎?

1.用python調用python腳本

創新互聯建站長期為成百上千家客戶提供的網站建設服務,團隊從業經驗10年,關注不同地域、不同群體,并針對不同對象提供差異化的產品和服務;打造開放共贏平臺,與合作伙伴共同營造健康的互聯網生態環境。為內鄉企業提供專業的成都做網站、成都網站設計,內鄉網站改版等技術服務。擁有10多年豐富建站經驗和眾多成功案例,為您定制開發。

#!/usr/local/bin/python3.7
import time
import os 

count = 0
str = ('python b.py')
result1 = os.system(str)
print(result1)
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')

另外一個python腳本b.py如下:

#!/usr/local/bin/python3.7
print('hello world')

運行結果:

[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調用shell方法os.system()

'''
遇到問題沒人解答?小編創建了一個Python學習交流QQ群:579817333 
尋找有志同道合的小伙伴,互幫互助,群里還有不錯的視頻學習教程和PDF電子書!
'''
#!/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"

運行結果:

[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

3.python調用shell方法os.popen()

'''
遇到問題沒人解答?小編創建了一個Python學習交流QQ群:579817333 
尋找有志同道合的小伙伴,互幫互助,群里還有不錯的視頻學習教程和PDF電子書!
'''
#!/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')

運行結果:

[python@master2 while]$ python a.py 
<os._wrap_close object at 0x7f7f89377940>
['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

os.system.popen() 這個方法會打開一個管道,返回結果是一個連接管道的文件對象,該文件對象的操作方法同open(),可以從該文件對象中讀取返回結果。如果執行成功,不會返回狀態碼,如果執行失敗,則會將錯誤信息輸出到stdout,并返回一個空字符串。這里官方也表示subprocess模塊已經實現了更為強大的subprocess.Popen()方法。

文章題目:3種python調用其他腳本的方法,你還知道其他的方法嗎?
當前路徑:http://m.2m8n56k.cn/article6/ijccig.html

成都網站建設公司_創新互聯,為您提供網站設計商城網站虛擬主機網站排名App開發

廣告

聲明:本網站發布的內容(圖片、視頻和文字)以用戶投稿、用戶轉載內容為主,如果涉及侵權請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網站立場,如需處理請聯系客服。電話:028-86922220;郵箱:[email protected]。內容未經允許不得轉載,或轉載時需注明來源: 創新互聯

微信小程序開發
主站蜘蛛池模板: 午夜限制r级噜噜片一区二区 | 大陆精品自在线拍国语 | 久久精品国产精品亚洲艾 | 免费韩国美女爽快一级毛片 | 午夜影院在线免费 | 毛片免费在线播放 | 亚洲欧美一区二区三区在线播放 | 国产成人麻豆tv在线观看 | 免费精品久久 | 亚洲韩国欧美一区二区三区 | 中国成人免费视频 | 鲁丝一区二区三区不属 | 亚洲男女视频 | 18成人网| 日本网址在线观看 | 国产在线欧美日韩精品一区二区 | 欧美国产成人免费观看永久视频 | 香蕉成人国产精品免费看网站 | 亚洲欧美日韩国产精品久久 | 久久在线视频播放 | 国产精品亚欧美一区二区三区 | 国产高清美女一级a毛片久久 | 欧美毛片a级毛片免费观 | 大尺度福利视频在线观看网址 | 末成年娇小性色xxxxx | 国产免费人视频在线观看免费 | 亚洲精品综合一区二区三区 | 久久偷看各类wc女厕 | 国内精品久久久久久 | 亚洲小视频在线播放 | 手机看片高清国产日韩片 | 亚洲国产欧美在线人成aaa | 国产在线免 | 99在线视频免费观看 | 久久91精品国产99久久yfo | ffee性xxⅹ另类老妇hd | 女人把腿劈开让男人桶的网站 | 亚洲高清一区二区三区 | 日本成人在线看 | 日韩一级不卡 | 久久精品国产亚洲7777小说 |