我正在处理代码,并使用warnings库抛出了很多(对我而言)无用的警告.阅读(/扫描)文档我只发现了一种禁用单个函数警告的方法.但我不想改变这么多的代码.
可能有旗帜python -no-warning foo.py吗?
你会推荐什么?
我一直这样:
DeprecationWarning: integer argument expected, got float
Run Code Online (Sandbox Code Playgroud)
如何让这条消息消失?有没有办法避免Python中的警告?
我在Python 2.5中使用ZipFile创建一个ZIP文件,它到目前为止工作正常:
import zipfile, os
locfile = "test.txt"
loczip = os.path.splitext (locfile)[0] + ".zip"
zip = zipfile.ZipFile (loczip, "w")
zip.write (locfile)
zip.close()
Run Code Online (Sandbox Code Playgroud)
但我找不到如何加密ZIP文件中的文件.我可以使用系统并调用PKZIP -s,但我想必须有更"Pythonic"的方式.我正在寻找一个开源解决方案.