【发布时间】:2013-04-23 16:08:35
【问题描述】:
我正在寻找一种将我的 PHP 代码合并到我的 Python 文件中的方法。也许很奇怪,但对我来说这会很有帮助。我只是想要这部分 PHP 代码在 Python 中,因为我不知道如何用 Python 重写它:(
function counter_winkelkar()
{
global $order;
global $refname;
if(isset( $_POST['clearknop'] ))
{
$_SESSION['count']= '0';
unset($_SESSION['array_products']);
unset($_SESSION['array_counting_products']);
}
if (isset( $_POST['refname'] ))
{
$_SESSION['count']= $_SESSION['count'] + $order;
print("$_SESSION[count]");
}
}
function products_winkelkar()
{
global $order;
global $db;
global $refname;
if (!isset($_SESSION['array_products']) )
{
$_SESSION['array_products'] = Array();
$_SESSION['array_counting_products'] = Array();
}
if ($order != 'number' )
{
array_push($_SESSION['array_products'],$refname);
array_push($_SESSION['array_counting_products'],$order);
}
}
function winkelkar()
{
counter_winkelkar();
products_winkelkar();
}
winkelkar();
?>
【问题讨论】:
-
您的 PHP 代码引用了 $_POST 和 $_SESSION,这表明它应该在 http 服务器的上下文中运行。 Python 如何适应这种设置?
-
他想把它改写成python
标签: php python forms session python-2.7