开发者社区 问答 正文

使用按位取反~

使用按位取反~

展开
收起
珍宝珠 2019-11-19 16:50:08 2483 分享 版权
1 条回答
写回答
取消 提交回答
  • #!/usr/bin/python
    # -*- coding: UTF-8 -*-
    
    if __name__ == '__main__':
        a = 234
        b = ~a
        print 'The a\'s 1 complement is %d' % b
        a = ~a
        print 'The a\'s 2 complement is %d' % a
    
    

    以上实例输出结果为:

    The a's 1 complement is -235
    The a's 2 complement is -235
    
    2019-11-19 16:50:26
    赞同 展开评论
问答地址: