别名的用处
Python要使用时间戳,顺理成章使用time.time()。
x_ca_timestamp =str(int(round(time.time())*1000))
结果错误:
Django Version:
2.1.15
Exception Type:
AttributeError
Exception Value:
type object 'datetime.time' has no attribute 'time'
原因是datetime 和 time这两个module导致的,最后使用了别名
import time as tm
import datetime
x_ca_timestamp =str(int(round(tm.time())*1000)) 成功执行
取别名tm ,就是骂人口头禅的简写,也算发泄一下,因为这个小问题花了很多时间。