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

来源:互联网 发布:什么叫软件测试 编辑:程序博客网 时间:2024/04/30 23:40

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


0 0
原创粉丝点击