标签:程序 star UNC name sys cti __name__ tar bin
主程序:main.py
#!/usr/bin/env python # -*- coding: utf-8 -*- import sys import article import threading if __name__ == ‘__main__‘: for i in range(10): if i % 2 == 0: t1 = threading.Thread(target = article.sleep, args = ("sleep function",)) t1.start() else: article.publish("publish function")
模块程序:
#!/usr/bin/env python # -*- coding: utf-8 -*- import sys import time def sleep(msg): time.sleep(2) print msg def publish(msg): print msg if __name__ == ‘__main__‘: publish("publish") sleep("sleep")
output
publish function publish function publish function publish function publish function sleep functionsleep functionsleep functionsleep function sleep function
标签:程序 star UNC name sys cti __name__ tar bin
原文地址:https://www.cnblogs.com/yuanzhenliu/p/8777499.html