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()))


你可能感兴趣的:(python)