我有一个 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