如何在python程序中执行另一个程序?

我对python非常陌生(大约有两天的经验),到目前为止已经编写了一些基本程序。现在我想尝试制作一个程序,用户可以在其中输入文件名并执行文件,但我还没有找到我需要的最后一块。到目前为止,我有一个基本的:

选择 | 换行 | 行号
  1. print "Enter program name.\nFor a list of programs type 'List'" #intro text
  2. program = raw_input("Program: ") #asks user for program
  3. while program == "List": #lists program names
  4.     print "Collatz.py"
  5.     #the program list continues with a few more names
  6.     program = raw_input("Program: ") #asks for new input
  7.  

我已经尝试了50种不同的方法来让程序正常运行,但我似乎无法让它工作。

标签: python

添加新评论