Python语法备忘

==========  原创作品    作者:未闻    出处:博客园  ==========

获取当前时间戳

# 获取当前时间戳
ts = time.time()
# 获取10位时间戳
ts10 = int(ts)
# 获取13位时间戳
ts13 = int(round(time.time()) * 1000)

 执行js文件

import execjs # pip install PyExecJS

js_txt = """
function add(a, b){return a+b}
"""
ctx = execjs.compile(js_txt)
print(ctx.call("add", 1, 2))

参考资料

原文地址:https://www.cnblogs.com/yokeqi/p/12928334.html