问题描述
我正在使用 tempfile Python 模块来创建临时文件。我需要写入文件,然后我需要更改文件的模式,使其为只读(chmod 400)。有没有办法使用 tempfile 模块本身来做到这一点?或者我应该考虑使用子流程来实现这一目标?例如subprocess.run(["chmod","400",tmp_file.name])
这是一个例子:
import tempfile
tmp_file = tempfile.NamedTemporaryFile() # by default this tempfile will have write permissions
tmp_file.write(b'Hello World!')
tmp_file.chmod(400) # I need to be able to change the permissions of the tempfile after I've written to it
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)