社区所有版块导航
Python
python开源   Django   Python   DjangoApp   pycharm  
DATA
docker   Elasticsearch  
aigc
aigc   chatgpt  
WEB开发
linux   MongoDB   Redis   DATABASE   NGINX   其他Web框架   web工具   zookeeper   tornado   NoSql   Bootstrap   js   peewee   Git   bottle   IE   MQ   Jquery  
机器学习
机器学习算法  
Python88.com
反馈   公告   社区推广  
产品
短视频  
印度
印度  
私信  •  关注

Michael Schneider

Michael Schneider 最近创建的主题
Michael Schneider 最近回复了
15 年前
回复了 Michael Schneider 创建的主题 » 如何在PyCharm中按顺序运行代码?

如果你想要测试1。py将保持可执行,其功能与调用内部服务时相同。py,然后做一些类似的事情:

测试1。py

def main():
    print "I am a test"
    print "see! I do nothing productive."

if __name__ == "__main__":
    main()

服务py

import test1
# lots of stuff here
test1.main() # do whatever is in test1.py