0在linux中、python、 c中的区别

 

001、0在linux 中表示True? 

root@PC1:/home/test2# [ 3 -gt 1 ]    ## 判断为真, 这$?为0, True为0??
root@PC1:/home/test2# echo $?              
0

 

 

002、python 中True表示为1

>>> False + False                   ## python 中 False为0, True为1
0
>>> False + True
1
>>> True + True
2

 

003、c中True为非0, False为0

#include <stdio.h>

int main(void)
{
    if (0)                              ## False为0
    {
        puts("000");
    }
    else                                ## 非0位True
    {
        puts("no 0");
    }
    
    return 0;
} 

 

 

 

 

 

 

posted @ 2022-08-11 22:01  小鲨鱼2018  阅读(338)  评论(0编辑  收藏  举报