韩漫免费漫画在线观看方法,《好好疼爱里面》免费看,年轻漂亮的女士护士内衣,妈妈醉酒后把我当爸爸电视剧

文章 > Python基础教程 > 如何调用python中的shell脚本?

如何调用python中的shell脚本?

调用python中的shell脚本

头像

2020-11-13 17:58:503462浏览 · 0收藏 · 0评论

相信大家对于这块了解应该挺丰富了吧,小编早几期一直给大家教大家相关的内容,不知道现在在给大家提及,脑子里会不会有些许印象呢?或者,大家可不可以给小编完成这次我们文章的问题呢?最起码大家心里应该知道怎么去调用一些脚本了吧,那大家根据自己的想像,在看下下文小编给的内容,结合起来,优化下吧~

1. python调用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"

运行结果:

[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.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')

运行结果:

[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

好啦,大家看下是否跟平常调用方式一不一样呢?大概都能看出来关于python调用脚本时候,大致都是这样子的吧,那大家如果遇到类似问题,可以举一反三学习哦~

关注

关注公众号,随时随地在线学习

本教程部分素材来源于网络,版权问题联系站长!

按摩师把我添高潮了6次| 儿子耕种母亲的田地的收获| 公交车上萌蒂添的好舒服H漫画| 第一次和公翁做爰又大又粗| 向南| 爸井空电影| 好保姆| 坤坤寒入桃子里电视剧| 玉茎入玉门的正确方法图片| 我在开会他在下添好爽| 两个老头把我添高潮了| 人犬兽人在线观看免费完整| 放荡的女兵伦理2| 酒鬼酒股票| 亚洲一区二区三区| 把腿开大点我添添你SB| 他的大手在秘密花园游走漫画| 高压监狱2法国1时43分| 儿子控制不住对妈妈发脾气怎么办| 福艳都市韵母王雪琴| 妈妈俱乐部1-34节小说| 大夜| 狗锁女人全集免费播放| 69精品久久久久久久精品A片| 《法国空乘4》在线观看| 美女被捆绑绳子穿过下体 勒胸| 广汇能源股吧| 华丽的外出在线观看| 《老公请部长家里吃饭》日剧| 中国VITAFUSION孕妇| 15岁女初中生免费观看电视剧| 美国式禁忌| 暴躁老妈高清免费观看电视剧| 妈妈和两个姨妈一起过生日| 我把刘姨俩腿扛在肩上是哪一集的| 小雪被老汉各种姿势玩弄视频| 如何正确拔萝卜| 《爸开车我抱着妈妈去姥姥家》| 《性巴士1》| 美女和男生一起努力的生孩子视频.. | 《漾出OVER FLOWER》…