如何将文件拖到我创建的exe文件中(拖放图标)并在exe开始运行时将其作为参数?
答案 0 :(得分:2)
如果您创建以下代码,那么当您将文件拖到exe图标上时,args [0]会将其路径作为参数: (我添加了if语句,如果你启动程序而不拖动任何东西 它不应该崩溃)
from scipy import stats
p_data = [1, 1, 2, 4, 3, 8, 19, 11, 12, 7, 11, 12, 16, 7, 176, 62, 55, 44, 38, 48, 29, 28, 29, 35, 22, 32, 30, 36, 22, 33, 30, 30, 35, 20, 24, 33, 22, 28, 27, 32, 28, 13, 20, 9, 11, 12, 21, 13, 12, 18, 18, 16, 14, 12, 10, 15, 8, 14, 11, 19, 14, 11, 14, 12, 10, 12, 8, 7, 7, 7, 8, 5, 3, 10, 8, 10, 10, 8, 4, 6, 5, 3, 2, 8, 8, 8, 3, 8, 5, 7, 9, 2, 12, 5, 4, 3, 1, 9, 5, 3, 4, 4, 2, 5, 5, 5, 2, 1, 5, 6, 4, 2, 2, 1, 6, 3, 2, 6, 4, 5, 3, 2, 1, 2, 5, 3, 6, 3, 2, 1, 4, 1, 5, 4, 1, 2, 1, 2, 2, 2, 8, 2, 2, 4, 6, 1, 4, 3, 3, 6, 2, 4, 1, 4, 3, 3, 5, 3, 3, 4, 4, 5, 3, 2, 1, 2, 3, 3, 1, 1, 1, 4, 3, 3, 5, 4, 4, 4, 1, 148]
thesum=sum(p_data)
p_data = [_/thesum for _ in p_data]
x_k = range(1, 1+len(p_data))
custom = stats.rv_discrete(name='custm', values=(x_k, p_data))
R = custom.rvs(size=1000)
print (R[:20])