TypeError:int()参数必须是字符串或数字,而不是';元组';使用couchdb python
我得到TypeError:int()参数必须是字符串或数字,而不是';元组';使用couchdb python,python,python-2.7,couchdb-python,Python,Python 2.7,Couchdb Python,我得到 如何修复类型错误?您需要删除代码中的逗号,这样就不会有错误 from couchdb.mapping import Document, TextField, IntegerField, Mapping from couchdb.mapping import DictField, ViewField, BooleanField, ListField from couchdb import Server # $ sudo systemctl start couchdb # http://l
如何修复类型错误?您需要删除代码中的逗号,这样就不会有错误
from couchdb.mapping import Document, TextField, IntegerField, Mapping
from couchdb.mapping import DictField, ViewField, BooleanField, ListField
from couchdb import Server
# $ sudo systemctl start couchdb
# http://localhost:5984/_utils/
class Test(Document):
type = TextField() # "Test"
name = TextField() # "name"
sub_name = TextField() # "B01"
pos = IntegerField() # 828288
s_type = IntegerField() # 1
_id = IntegerField() # x_type = 7
chr = ListField(DictField(Mapping.build(
letter=TextField(), # C
no=IntegerField(), # 5
)))
server = Server()
db = server.create("test")
r = [["Test", "A", "B01", 828288, 1, 7, 'C', 5],
["Test", "A", "B01", 828288, 1, 7, 'T', 6],
["Test", "A", "B01", 171878, 3, 8, 'C', 5],
["Test", "A", "B01", 171878, 3, 8, 'T', 6],
["Test", "A", "B01", 871963, 3, 9, 'A', 5],
["Test", "A", "B01", 871963, 3, 9, 'G', 6],
["Test", "A", "B01", 1932523, 1, 10, 'T', 4],
["Test", "A", "B01", 1932523, 1, 10, 'A', 5],
["Test", "A", "B01", 1932523, 1, 10, 'X', 6],
["Test", "A", "B01", 667214, 1, 14, 'T', 4],
["Test", "A", "B01", 667214, 1, 14, 'G', 5],
["Test", "A", "B01", 667214, 1, 14, 'G', 6]]
for i in r:
print i[3]
test = Test()
test.type = i[0],
test.name = i[1],
test.sub_name = i[2],
test.pos = i[3],
test.s_type = i[4],
test._id = i[5],
test.chr.append(
letter=i[6],
no=i[7]
)
test.store(db)
from couchdb.mapping import Document, TextField, IntegerField, Mapping
from couchdb.mapping import DictField, ViewField, BooleanField, ListField
from couchdb import Server
# $ sudo systemctl start couchdb
# http://localhost:5984/_utils/
class Test(Document):
type = TextField() # "Test"
name = TextField() # "name"
sub_name = TextField() # "B01"
pos = IntegerField() # 828288
s_type = IntegerField() # 1
_id = IntegerField() # x_type = 7
chr = ListField(DictField(Mapping.build(
letter=TextField(), # C
no=IntegerField(), # 5
)))
server = Server()
db = server.create("test")
r = [["Test", "A", "B01", 828288, 1, 7, 'C', 5],
["Test", "A", "B01", 828288, 1, 7, 'T', 6],
["Test", "A", "B01", 171878, 3, 8, 'C', 5],
["Test", "A", "B01", 171878, 3, 8, 'T', 6],
["Test", "A", "B01", 871963, 3, 9, 'A', 5],
["Test", "A", "B01", 871963, 3, 9, 'G', 6],
["Test", "A", "B01", 1932523, 1, 10, 'T', 4],
["Test", "A", "B01", 1932523, 1, 10, 'A', 5],
["Test", "A", "B01", 1932523, 1, 10, 'X', 6],
["Test", "A", "B01", 667214, 1, 14, 'T', 4],
["Test", "A", "B01", 667214, 1, 14, 'G', 5],
["Test", "A", "B01", 667214, 1, 14, 'G', 6]]
for i in r:
print i[3]
test = Test()
test.type = i[0],
test.name = i[1],
test.sub_name = i[2],
test.pos = i[3],
test.s_type = i[4],
test._id = i[5],
test.chr.append(
letter=i[6],
no=i[7]
)
test.store(db)
from couchdb.mapping import Document, TextField, IntegerField, Mapping
from couchdb.mapping import DictField, ViewField, BooleanField, ListField
from couchdb import Server
# $ sudo systemctl start couchdb
# http://localhost:5984/_utils/
class Test(Document):
type = TextField() # "Test"
name = TextField() # "name"
sub_name = TextField() # "B01"
pos = IntegerField() # 828288
s_type = IntegerField() # 1
_id = IntegerField() # x_type = 7
chr = ListField(DictField(Mapping.build(
letter=TextField(), # C
no=IntegerField(), # 5
)))
server = Server()
db = server.create("test")
r = [["Test", "A", "B01", 828288, 1, 7, 'C', 5],
["Test", "A", "B01", 828288, 1, 7, 'T', 6],
["Test", "A", "B01", 171878, 3, 8, 'C', 5],
["Test", "A", "B01", 171878, 3, 8, 'T', 6],
["Test", "A", "B01", 871963, 3, 9, 'A', 5],
["Test", "A", "B01", 871963, 3, 9, 'G', 6],
["Test", "A", "B01", 1932523, 1, 10, 'T', 4],
["Test", "A", "B01", 1932523, 1, 10, 'A', 5],
["Test", "A", "B01", 1932523, 1, 10, 'X', 6],
["Test", "A", "B01", 667214, 1, 14, 'T', 4],
["Test", "A", "B01", 667214, 1, 14, 'G', 5],
["Test", "A", "B01", 667214, 1, 14, 'G', 6]]
for i in r:
print i[3]
test = Test()
test.type = i[0]
test.name = i[1]
test.sub_name = i[2]
test.pos = i[3]
test.s_type = i[4]
test._id = i[5]
test.chr.append(
letter=i[6],
no=i[7]
)
test.store(db)