根据问题。我知道它与number % 5 == 0
做同样的事情,但我不明白。有人可以给它一个解释吗?
答案 0 :(得分:0)
from subprocess import Popen, PIPE
WINSCP = r'c:\<path to>\winscp.com'
class UploadFailed(Exception):
pass
def upload_files(host, user, passwd, files):
cmds = ['option batch abort', 'option confirm off']
cmds.append('open sftp://{user}:{passwd}@{host}/'.format(host=host, user=user, passwd=passwd))
cmds.append('put {} ./'.format(' '.join(files)))
cmds.append('exit\n')
with Popen(WINSCP, stdin=PIPE, stdout=PIPE, stderr=PIPE,
universal_newlines=True) as winscp: #might need shell = True here
stdout, stderr = winscp.communicate('\n'.join(cmds))
if winscp.returncode:
# WinSCP returns 0 for success, so upload failed
raise UploadFailed
以外的任何数字都是0
,所以True
3%5 = 3
和True
not True
是False
。因此True
的唯一时间是number % 5 == False or 0
,因为not False
是True
。
或
number % 5 == 0 = False == False = True
not(number % 5) = not False = True
如果这没有意义,我可以尝试用另一种方式解释它。