简体   繁体   English

AttributeError: 'collections.OrderedDict' 对象没有属性 'split'

[英]AttributeError: 'collections.OrderedDict' object has no attribute 'split'

with open(argv[1]) as csvfile:
    for character in csv.DictReader(csvfile):
        division_title = character.split()
        if len(division_title) < 3:
            db.execute("INSERT INTO students(first, middle, last, house, birth) VALUES(?, ?, ?, ?, ?)",
                       division_title[0], None, division_title[1], character[1], character[2])
        else:
            db.execute("INSERT INTO students(first, middle, last, house, birth) VALUES(?, ?, ?, ?, ?)",
                       division_title[0], division_title[1], division_title[2], character[1], character[2])

Error message:错误信息:

Traceback (most recent call last): File import.py, line 14, in <module>

错误信息

try by modifying start code as:尝试将启动代码修改为:

with open(argv[1]) as csvfile:
    data = csv.DictReader(csvfile)
    for character in data:
        division_title = data[character].split()

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Django AttributeError: &#39;collections.OrderedDict&#39; 对象没有属性 &#39;pk&#39; - Django AttributeError: 'collections.OrderedDict' object has no attribute 'pk' AttributeError: 'collections.OrderedDict' object 没有属性 'value_counts' - AttributeError: 'collections.OrderedDict' object has no attribute 'value_counts' AttributeError: &#39;collections.OrderedDict&#39; 对象没有属性 &#39;iloc&#39; - AttributeError: 'collections.OrderedDict' object has no attribute 'iloc' AttributeError: 'collections.OrderedDict' object 没有属性 'train' - AttributeError: 'collections.OrderedDict' object has no attribute 'train' Django - AttributeError: 'collections.OrderedDict' 对象没有属性 'id' - Django - AttributeError: 'collections.OrderedDict' object has no attribute 'id' “collections.OrderedDict”对象没有属性 - 'collections.OrderedDict' object has no attribute Django - &#39;collections.OrderedDict&#39; 对象没有属性 &#39;headers&#39; - Django - 'collections.OrderedDict' object has no attribute 'headers' &#39;collections.OrderedDict&#39; 对象没有属性 &#39;pk&#39; - django rest 框架 - 'collections.OrderedDict' object has no attribute 'pk' - django rest framework 预训练的 model 错误? 'collections.OrderedDict' object 没有属性 'eval' - pretrained model error ? 'collections.OrderedDict' object has no attribute 'eval' 如果不是 (target.size() == input.size()): AttributeError: 'collections.OrderedDict' object has no attribute 'size' 我收到此错误 - if not (target.size() == input.size()): AttributeError: 'collections.OrderedDict' object has no attribute 'size' I'm getting this error
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM