国产成人AV无码一二三区,少女1到100集,国产精品久久久久精品综合紧,巜公妇之诱感肉欲HD在线播放

文章 > 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调用脚本时候,大致都是这样子的吧,那大家如果遇到类似问题,可以举一反三学习哦~

关注

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

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

欧美电影免费观看大全能出没 | 日韩成人无码| 《情欲按摩院》未删减版| HTTPS://9.1.CRM...| 公媳欢情沈曼最新童节更新| 妈妈可以帮儿子解决心理需要| 生殖瑜伽| 妈妈醉酒后把我当爸爸电视剧| 三男一女免费播放电视剧大全 | 女列车长丰满乳峰| 白日梦我小说全文免费阅读 | 老翁玩嫩媳| 女人什么姿势下面最紧| 《法国空乘5》观看| 爆乳| 赠刘景文| 《部长连续几天让我失去理智》| 粗大挺进亲女小雅小滨| 《交换做爰》在线观看| 《公天天吃我奶躁我》| 娇妻1~29被部长玩的经过| 办公室偷吻| 动物扌暴辶鬲的| 第一章激情艳妇| 坐在教授的根茎上写句子漫画图片| 《警花交换做爰》| B站夫妻进入高峰期需要多久| 欧洲女性下面有没有毛发| 一线产区和二线产区的标准图| 正常硬度是多硬| 舒淇| 午马影视免费观看电视剧 | 啵啵| 韩漫网址| 三男一女CP免费观看电视剧大全| 欧美精品99久久久啪啪| 主动把乳头放进男朋友嘴巴里| 豆传媒剧国产MV有什么特点| 妈妈和女婿免费播放电视剧| 《出租屋1》| 真人姓交