“不是数字%5”是什么意思? (蟒蛇)

时间:2015-10-29 17:16:04

标签: python python-2.7

根据问题。我知道它与number % 5 == 0做同样的事情,但我不明白。有人可以给它一个解释吗?

1 个答案:

答案 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 = 3True not TrueFalse。因此True的唯一时间是number % 5 == False or 0,因为not FalseTrue

number % 5 == 0  =  False == False = True
not(number % 5)  =  not False      = True

如果这没有意义,我可以尝试用另一种方式解释它。