小编Coo*_*dio的帖子

使用PyInstaller制作的.app立即关闭?

我试图使用PyInstaller将python程序转换为.app。实际的代码可以通过IDLE正常运行,但是每次我尝试运行新转换的.app时,它都会立即关闭。以下是我的.spec文件和.py文件。我已经编辑了.spec文件,并在导入的.py文件中添加了文本文件。

PYTHON文件:

#CENTRALCOAST: 2250-2420
#CENTRALCOAST2: 2250-2267
#NORTHERNBEACHES: 2084-2108
CentralCoast = []
NorthernBeaches = []
OOR = []
Invalid = []
import math
def numLen(num):
  return len(str(abs(num)))

with open('postcodes.txt') as input_file:
    long_list = [line.strip() for line in input_file]
    for i in range(len(long_list)):
        long_list[i] = int(long_list[i])
for each in long_list:
    if 2084 <= each <= 2108: #NorthernBeaches
        NorthernBeaches.extend([each])
for each in long_list:
    if 2250 <= each <= 2267: #CentralCoast
        CentralCoast.extend([each])
for each in long_list:
    if not 2250 <= each <= 2267:
        OOR.extend([each]) …
Run Code Online (Sandbox Code Playgroud)

python pyinstaller

3
推荐指数
5
解决办法
7149
查看次数

如何在Python中为random.randint添加异常?

所以我有一个变量,它创建一个0到10之间的随机数,但是,我不希望创建的随机数为5.我如何在Python中添加random.randint的异常?我下面的内容不是这样做的:

number = random.randint(0, 10) !=5
Run Code Online (Sandbox Code Playgroud)

这只是根据随机数是否等于5而返回True或False ...我该如何解决这个问题?

python random

0
推荐指数
2
解决办法
1751
查看次数

标签 统计

python ×2

pyinstaller ×1

random ×1