csv reader behavior with None and empty string

后端 未结 7 1471
夕颜
夕颜 2020-12-01 13:59

I\'d like to distinguishing None and empty strings when going back and forth between Python data structure and csv representation using Python\'s csv

7条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-01 14:44

    As you have control over both the consumer and the creator of the serialised data, consider using a format that does support that distinction.

    Example:

    >>> import json
    >>> json.dumps(['foo', '', None, 666])
    '["foo", "", null, 666]'
    >>>
    

提交回复
热议问题