小编Sea*_*Xie的帖子

如何减少cx_Freeze编译的Python可执行文件的大小?

我已经用cx_Freeze. Python 代码本身只有 195 行长。然而,我编译的程序有500 MB。我使用matplotlibnumpypymsgbox和 我不知道我的库是否对我编译的程序大小有那么大的影响。

造成这种意外文件大小的原因是什么?有没有办法减少可执行文件的大小?

python exe cx-freeze

4
推荐指数
1
解决办法
1374
查看次数

字符串replace()无法按预期工作

replace()在python中遇到了一些麻烦。这是我的代码:

string = input()
word = string.find('word')
if word >= 1:
    string = string.replace('word', 'word.2')
print(string)
Run Code Online (Sandbox Code Playgroud)

输出结果为word。不是word.2吗?我糊涂了。有什么帮助吗?

编辑:经过一段时间解决问题后,我发现问题现在是“为什么string.find('word')输入等于0 word

python replace find

0
推荐指数
1
解决办法
110
查看次数

标签 统计

python ×2

cx-freeze ×1

exe ×1

find ×1

replace ×1