从脚本中指定的代码生成可执行文件

Make executable from code specified in a script

是否可以从脚本中指定数量的代码创建可执行文件?

例如:

#some code up here to set some things up

def oneFunction(param):
    #does something here as well

def run():
    varaible1 = input()
    oneFunction(variable1)
    #more code after this

if something == True:
    #some code to create executable from the run function
else:
    #do something else

您可以使用 cx_freeze 从您的 py 文件创建可执行文件。
https://cx-freeze.readthedocs.io/en/latest/overview.html