V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
推荐学习书目
Learn Python the Hard Way
Python Sites
PyPI - Python Package Index
http://diveintopython.org/toc/index.html
Pocoo
值得关注的项目
PyPy
Celery
Jinja2
Read the Docs
gevent
pyenv
virtualenv
Stackless Python
Beautiful Soup
结巴中文分词
Green Unicorn
Sentry
Shovel
Pyflakes
pytest
Python 编程
pep8 Checker
Styles
PEP 8
Google Python Style Guide
Code Style from The Hitchhiker's Guide
bestehen
V2EX  ›  Python

Python 调用 nodejs 取结果 用下面这种方法如何写?

  •  
  •   bestehen · 2018-08-20 02:50:09 +08:00 · 1991 次点击
    这是一个创建于 2047 天前的主题,其中的信息可能已经有所发展或是发生改变。

    python 用 os.popen 调用 node 然后取结果

    3 条回复    2018-08-22 09:49:48 +08:00
    huaerxiela
        1
    huaerxiela  
       2018-08-20 10:50:19 +08:00
    用 execjs 啊
    bestehen
        2
    bestehen  
    OP
       2018-08-22 00:40:22 +08:00
    @huaerxiela 我说调用 nodejs 不是 js
    huaerxiela
        3
    huaerxiela  
       2018-08-22 09:49:48 +08:00
    @bestehen 直接用 execjs 执行 node 代码得出返回值便是,为什么要再去用 os 去调 node 命令行? 要是涉及到浏览器执行 js 就 pyppeteer 或者进一步封装的 requests_html 去执行 js 代码,也不需要用到你说的那种,如果我没理解错你的问题的话,感觉你现在选取的技术策略有那么一点问题
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   5483 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 27ms · UTC 08:21 · PVG 16:21 · LAX 01:21 · JFK 04:21
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.