之前用python3.5编写代码,现在要让程序在2.7中运行。结果debug了一个多钟头,发现在python3.5中,1/20==0.05, 而在python2.7中,1/20=0, 结果导致一个大的dataframe全为0值。 可以用1.0/x来解决,但是更方便的是在程序开头: import __future__ division
另外,python3统一用unicode编码,python2中则要根据情况encode和decode,所以可以 import __future__ unicode_literals