在 C 语言中有没有等同于 char 数据类型的 python 数据类型? 在 C 中,一个 char 变量只能存储 1 个字节的信息。例如 C 代码及其输出
void main()
{
char a;
printf("Enter the value");
scanf("%d",&a);
printf("A = %d",a);
}
输出
Enter the value 255 A = 255 Enter the value 256 A = 0
我想要 python 中的准确输出。请帮我。提前致谢。
最佳答案
鉴于您的用例是您想要模块化行为,只需将您的输入作为一个 int,然后执行 a%256
以找到您想要的结果。
关于python 等效于 C 中的 char 数据类型,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18128101/