python中执行其他的python脚本(三):

代码:

import os

#os.system('python hello1.py')

while 1:
    print("****************
")
    print("****************
")
    num = input("please input a num: ")
    try:
        print(num)
        if num == 'a':
            os.system('python hello1.py')
        if num == 2:
            os.system('python ')
            print(successful)
        if num == 3:
            os.system('python ')
        if num == 4:
            print("****************
")
            print("****************
")
            break

    except ValueError:
        print("It's not a num, Please enter again
")

用os组件函数实现

原文地址:https://www.cnblogs.com/guochaoxxl/p/13831887.html