av一区二区在线观看_亚洲男人的天堂网站_日韩亚洲视频_在线成人免费_欧美日韩精品免费观看视频_久草视

您的位置:首頁技術(shù)文章
文章詳情頁

簡單了解python調(diào)用其他腳本方法實(shí)例

瀏覽:5日期:2022-08-01 09:40:59

1.用python調(diào)用python腳本

#!/usr/local/bin/python3.7import timeimport os count = 0str = (’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’)

另外一個(gè)python腳本b.py如下:

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

運(yùn)行結(jié)果:

[python@master2 while]$ python a.py hello worldthis count is: 1this count is: 2this count is: 3this count is: 4this count is: 5this count is: 6this count is: 7this count is: 8Good Bye

2.python調(diào)用shell方法os.system()

#!/usr/local/bin/python3.7import timeimport os count = 0n = 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/shecho 'hello world'

運(yùn)行結(jié)果:

[python@master2 while]$ python a.py hello worldthis count is: 1this count is: 2this count is: 3this count is: 4this count is: 5this count is: 6this count is: 7this count is: 8Good Bye

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

#!/usr/local/bin/python3.7import timeimport os count = 0n = 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 <os._wrap_close object at 0x7f7f89377940>[’hello worldn’]this count is: 1this count is: 2this count is: 3this count is: 4this count is: 5this count is: 6this count is: 7this count is: 8Good Bye

os.system.popen() 這個(gè)方法會(huì)打開一個(gè)管道,返回結(jié)果是一個(gè)連接管道的文件對(duì)象,該文件對(duì)象的操作方法同open(),可以從該文件對(duì)象中讀取返回結(jié)果。如果執(zhí)行成功,不會(huì)返回狀態(tài)碼,如果執(zhí)行失敗,則會(huì)將錯(cuò)誤信息輸出到stdout,并返回一個(gè)空字符串。這里官方也表示subprocess模塊已經(jīng)實(shí)現(xiàn)了更為強(qiáng)大的subprocess.Popen()方法。

以上就是本文的全部內(nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持好吧啦網(wǎng)。

標(biāo)簽: Python 編程
相關(guān)文章:
主站蜘蛛池模板: 黑人黄色一级片 | 免费性爱视频 | 日韩一区不卡 | 天天操操操 | 人人射人人干 | 精品伊人久久 | 亚洲h视频 | 一区二区欧美日韩 | 日韩精品视频一区二区三区 | 依人久久 | 国产精品成人免费一区久久羞羞 | 国产福利一区二区三区 | 黄色精品视频 | 四虎影院在线播放 | 人人干人人艹 | 国产午夜av | 久草免费在线观看视频 | 日本不卡在线视频 | 亚洲一区二区三区中文字幕 | 欧美视频一二三区 | 国产美女视频网站 | 九九热精品在线 | 亚洲国产免费 | 欧美日韩少妇 | 中国一级黄色录像 | 免费看黄视频网站 | 国产精品婷婷 | 久久成人一区 | 午夜黄色剧场 | 激情导航 | 亚洲精品一区二区三区在线 | 婷婷91 | 91亚色视频 | 日韩免费精品视频 | 丁香六月综合 | 五月天.com | 中文字幕在线看 | 国产日韩欧美一区二区 | 欧美黑人猛交 | 女人一级一片30分 | 99re在线视频|