我想在Django数据库中存储一个列表。我应该使用哪个模型字段以及如何使用。我尝试了ArrayField,但它没有列表。
from django.contrib.postgres.fields import ArrayField
from django.db import models
class signup(models.Model):
userid=models.CharField(max_length=10)
password=models.CharField(max_length=10)
list=ArrayField(models.IntegerField(null=True,blank=True),size=5,null=True)
score=models.IntegerField(default=0)
Run Code Online (Sandbox Code Playgroud) 我正在尝试使用以下代码更改映射:
PUT /in_test/_mapping/keyword
{
"properties" : {
"term" : {
"type" : "text",
"index" : "not_analyzed"
}
}
}
Run Code Online (Sandbox Code Playgroud)
但它给出了一个错误:
{
"error": {
"root_cause": [
{
"type": "remote_transport_exception",
"reason": "[tiebreaker-0000000000][172.17.0.24:19555][indices:admin/mapping/put]"
}
],
"type": "illegal_argument_exception",
"reason": "Could not convert [term.index] to boolean",
"caused_by": {
"type": "illegal_argument_exception",
"reason": "Failed to parse value [not_analyzed] as only [true] or [false] are allowed."
}
},
"status": 400
}
Run Code Online (Sandbox Code Playgroud)
我还尝试通过以下方式重新创建索引:
PUT /in_test
{
"mappings" : {
"keyword" : {
"properties" : {
"term" : {
"type" …Run Code Online (Sandbox Code Playgroud) 这是该计划: -
#include<stdio.h>
int main()
{
int a[8]={1,2,3,4,5,6,7,8,9},i;
char* p;
p=(char*)a;
printf("%d",*p);
for( i=0;i<32;i++)
{
p=p+1;
printf("%d",*p);
}
return 0;
}
Run Code Online (Sandbox Code Playgroud)
输出: -
$ ./a.out
100020003000400050006000700080000
Run Code Online (Sandbox Code Playgroud)
为什么输出是这样的?
为什么有三个零后跟数组的值?
char指针增加1个字节.存储在内存中的二进制表示形式为0000000 00000000 00000000 00000001.是吗?所以输出应该像0 0 0 1.如果错误请解释.