【发布时间】:2010-11-06 19:43:51
【问题描述】:
我有一个 PHP 脚本 (news-generator.php),当我包含它时,它会抓取一堆新闻并打印出来。现在,我正在为我的网站 (CGI) 使用 Python。当我使用 PHP 时,我在“新闻”页面上使用了这样的内容:
<?php
print("<h1>News and Updates</h1>");
include("news-generator.php");
print("</body>");
?>
(为简单起见,我删减了示例。)
有没有办法让 Python 执行脚本 (news-generator.php) 并返回可以跨平台工作的输出?这样,我可以这样做:
page_html = "<h1>News and Updates</h1>"
news_script_output = php("news-generator.php") //should return a string
print page_html + news_script_output
【问题讨论】:
-
“为了简单起见,我简化了示例。” ——你还会为了什么简化它? ;)
-
@musicfreak:傻笑?效率?美女?
-
我曾与“简化示例”的人一起工作,以掩盖他们的无能。我希望这里不是这样。
标签: php python scripting integration execution