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.
我知道如何使用以下代码实现 chmod u+w:
st = os.stat(dest_file) os.chmod(dest_file, st.st_mode | stat.S_IWUSR)
但是uw呢?
st = os.stat(dest_file) os.chmod(dest_file, st.st_mode & ~stat.S_IWUSR)
说明:~是按位 NOT 运算符,因此按位 AND with~stat.S_IWUSR清除st.st_mode.
~
~stat.S_IWUSR
st.st_mode
用虚值来说明:
stat.S_IWUSR 00001000 ~stat.S_IWUSR 11110111 s.st_mode 00101001 s.st_mode & ~stat.S_IWUSR 00100001