怎么用python调用另一个python脚本


 

小编给大家分享一下怎么用python调用另一个python脚本,希望大家阅读完这篇文章后大所收获,下面让我们一起去探讨吧!

用python调用python脚本

#!/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

看完了这篇文章,相信你对怎么用python调用另一个python脚本有了一定的了解


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM