Py学习  »  pycharm

如何在PyCharm中按顺序运行代码?

leonardo • 2 年前 • 718 次点击  

我有一个脚本名为 test1.py 它不在模块中。它只有在脚本本身运行时应该执行的代码。没有函数、类、方法等。我有另一个作为服务运行的脚本。我想打电话 测试1。py 来自作为服务运行的脚本。

例如:

文件 测试1。py :

print "I am a test"
print "see! I do nothing productive."

文件 service.py :

# Lots of stuff here
test1.py # do whatever is in test1.py

我知道有一种方法,就是打开文件,读取内容,然后基本上对其进行评估。我想有更好的方法。至少我希望如此。

Python社区是高质量的Python/Django开发社区
本文地址:http://www.python88.com/topic/133621
 
718 次点击  
文章 [ 16 ]  |  最新文章 2 年前