![图片[1]-python怎么运行js文件?-uusu优素-乐高,模型,3d打印,编程](http://uusucn.zbbe.cn/wp-content/uploads/2024/01/5ee9b293bc84c397.jpg)
1,首先通过,get_js方法,读取本地的 des_rsa.js 文件。
2,调用 execjs.compile() 编译并加载 js 文件内容。
importexecjs
#执行本地的js
defget_js():
#f=open("D:/WorkSpace/MyWorkSpace/jsdemo/js/des_rsa.js",'r',encoding='UTF-8')
f=open("./js/des_rsa.js",'r',encoding='UTF-8')
line=f.readline()
htmlstr=''
whileline:
htmlstr=htmlstr+line
line=f.readline()
returnhtmlstr
jsstr=get_js()
ctx=execjs.compile(jsstr)
print(ctx.call('enString','123456'))
functionenString(data){
varkey1="YHXWWLKJYXGS";
varkey2="ZFCHHYXFL10C";
varkey3="DES";
varenchex=strEnc(data,key1,key2,key3);
returnenchex;
}原文来自:https://www.py.cn © 版权声明
文章版权归作者所有,未经允许请勿转载。
THE END



















































暂无评论内容