Python TypeError: coercing to Unicode: need string or buffer, float found

调试Python程序:

unique_key = name + time.mktime(create_time.timetuple())

提示错误:

TypeError: coercing to Unicode: need string or buffer, float found

错误原因:使用“+”拼接会抛出异常,改用%操作符输出

    unique_key = u'%s%s' % (name, time.mktime(create_time.timetuple()))

转载自:https://blog.csdn.net/Sherry_Rui/article/details/62219452

You may also like...