简体   繁体   English

如何使用Python防止文件被复制?

[英]How do I use Python to prevent a file from being copied?

I have a file that I need to "protect" so that it cannot be copied! 我有一个需要“保护”的文件,因此无法复制! I am using Python on Windows XP. 我在Windows XP上使用Python。

I think it may just be changing file permissions?? 我认为可能只是在更改文件权限??

You can prevent the file being copied only by removing read permission from the user that shouldn't be able to copy the file. 您可以仅通过从不应复制文件的用户中删除读取权限来防止文件被复制。 You can use os.chmod for this, or see this page explaining to set permissions with the full Windows security model. 您可以为此使用os.chmod ,或参阅此页面说明使用完整的Windows安全模型设置权限。

Is this a temporary or a permanent file? 这是临时文件还是永久文件? If it's temporary, take a look at the tempfile module, especially tempfile.mkstemp() . 如果是临时的,请看一下tempfile模块,尤其是tempfile.mkstemp()

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM