问题描述
在this location的python2.7中使用s2sphere库时,出现以下错误。
C = {k: A.get(k,['0']) + B.get(k,['0']) for k in A.keys() | B.keys()}
ljust() argument 2 must be char,not unicode
该文件似乎是ASCII编码的,所以我想知道为什么会出现这种情况
解决方法
文件在顶部导入unicode_literals:
from __future__ import print_function,unicode_literals,division
因此,“ 0”是一个unicode字符串,并且“ token”参数必须是unicode才能匹配