astTools.py 文件源码

python
阅读 28 收藏 0 点赞 0 评论 0

项目:ITAP-django 作者: krivers 项目源码 文件源码
def basicFormat(x):
    """Given an AST, turn it into its value if it's constant; otherwise, leave it alone"""
    if type(x) == ast.Num:
        return x.n
    elif type(x) == ast.NameConstant:
        return x.value
    elif type(x) == ast.Str:
        return x.s
    elif type(x) == ast.Bytes:
        return x.s
    return x # Do not change if it's not a constant!
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号