Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
是否有任何 python 模块使用我们可以创建一个新的 pdf 文件或修改现有的只有读取权限的 pdf 文件。我想禁用 pdf 文件的“另存为”和“另存为其他格式”。(DRM 的事情。)
我不确定这是可移植的,但你可以使用 os.chmod:
import os from stat import S_IREAD, S_IRGRP, S_IROTH filename = "yourfile.pdf" # Open the file and write your stuff to the file etc... os.chmod(filename, S_IREAD|S_IRGRP|S_IROTH)
感谢: 在 Python 中将文件更改为只读模式