python调用脚本_如何用python调用另一个python脚本?

1605863698381166.png

如果想要将已经设置好的内容,在转移到另一个位置要怎么做呢?小编能写到的方法有,照抄,复制,以及转移使用。在我们日常办公上是非常好理解的,就是ctr+v,但是如果想在编程上,将某一位置拿去到别的项目上使用,我们要怎么做呢?想必聪明的小伙伴们都想到了,去调用,那就让我们来看下怎么去调用本期标题吧!

用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学习网即可哦~

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值