# my_package/__main__.pyimportsysfrom.coreimportmain_logic# 从包的其他文件导入核心逻辑defmain():print("Welcome to My Package CLI!")args=sys.argv[1:]# 处理参数并执行main_logic(args)if__name__=="__main__":main()
注:虽然文件本身就是 __main__.py,但加上 if __name__ == "__main__": 依然是一个好习惯,防止它被意外 import 时直接执行。
We use cookies and similar methods to recognise visitors and remember preferences. We also use them to measure
campaign effectiveness and analyse site traffic.
By selecting 'Accept', you consent to the use of these methods by us and trusted third parties.