Python coding error solutions

Python coding error solutions

Python

UnicodeDecodeError: 'ascii' codec can't decode byte 0xe5 in position 7: ordinal not in range(128)

solution:

import sys
reload(sys)
sys.setdefaultencoding('utf8')

Of course, if you need a non-shell environment to the head

#coding:utf-8

Before doing Flask when it needs some strange errors

If the computer name with Chinese words is to be wrong, so it is best English

If you encounter pandas IO sometimes garbled

df.to_excel('result.xlsx',encoding="utf_8_sig")

Finally, attach a small knowledge

pandas If you want to find the difference between the number of days after the date of subtraction

frame["date_delta"] /= np.timedelta64(1, 'D')

Guess you like

Origin www.cnblogs.com/stdpain/p/11325925.html