将部分函数调用保存在json文件中

时间:2019-02-04 18:32:53

标签: python json functools

我有一个字典来存储N个部分函数调用。

/** @var \TYPO3\CMS\Core\Database\Query\QueryBuilder $queryBuilder */
$queryBuilder = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Core\Database\ConnectionPool::class)->getQueryBuilderForTable('myTable');
/** @var \TYPO3\CMS\Core\Database\Connection $connection */
$connection = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Core\Database\ConnectionPool::class)->getConnectionForTable('myTable');
$query = $queryBuilder
    ->select('*')
    ->from('myTable')
    ->where(
        $queryBuilder->expr()->orX(
            $queryBuilder->expr()->like(
                'street',
                $queryBuilder->createNamedParameter('%abc%', \PDO::PARAM_STR)
            ),
            $queryBuilder->expr()->like(
                'street_number',
                $queryBuilder->createNamedParameter('%abc%', \PDO::PARAM_STR)
            ),
            $queryBuilder->expr()->comparison(
                $connection->getDatabasePlatform()->getConcatExpression('street, \' \', street_number'),
                'LIKE',
                $queryBuilder->createNamedParameter('%abc%', \PDO::PARAM_STR)
            )
        )
    )
    ->execute();

效果很好。

如果我将此字典存储在.json文件中,则我的局部调用周围会带有引号

dict_ = {1: partial(FUNCTION, ARG1,ARG2,ARG3 )}

如何删除引号以执行代码?

dict_ =    {"1":"partial(FUNCTION, ARG1,ARG2,ARG3 )"}

返回ast.literal_eval(dict_ ['1'])

0 个答案:

没有答案