Day086 — what I learn in a python project

Jacky Tsang
2 min readJun 27, 2019

--

log exception

check if string is None and empty

bool(“”) and bool(None) are False

bool(“ “) is True, use .strip()

can use csv.QUOTE_NONE to avoid any quoting for csv.reader. Otherwise, by default, it will treat what inside an open and close quote as one string. It includes multiple lines of content as a value of one column.

match for a specific pattern

handle “Line contains NULL byte” error when using CSV reader

reader = csv.reader(x.replace(‘\0’, ‘’) for x in mycsv)

be care before adding new value to dict, it is best to use .copy() before adding new object to it. Same goes to array. Don’t loop an array and modify its item in that loop. It is not safe.

--

--

No responses yet