python跑代码的时候碰到Process finished with exit code -1073741571 (0xC00000FD)报错,网上搜了发现可能原因如下:
1. pycharm的内容空间不够。
解决方案:
(1)Help->Find Action->搜VM->
(2)修改-Xmx750m 成-Xmx3072m或其他,不要超过电脑内存,保存重启pycharm生效。
参考链接:https://blog.csdn.net/qq_31293215/article/details/88350910

2.递归导致的栈溢出
**解决方案:**尾递归优化。
修改前:


def tree_to_token_index(root_node):
    if (len(root_node.children) == 0 or root_node.type == 'string') and root_node.type != 'comment':
        return [(root_node.start_point, root_node.end_point)]
    else:
        code_tokens = []
        for child in root_node.children:
            code_tokens += tree_to_token_index(child)
        return code_tokens

修改方法:return 改为yeild,然后后面加上尾递归改造的函数

def tree_to_token_index(root_node):
    if (len(root_node.children) == 0 or root_node.type == 'string') and root_node.type != 'comment':
        yield  [(root_node.start_point, root_node.end_point)]
    else:
        code_tokens = []
        for child in root_node.children:
            code_tokens += tree_to_token_index(child)
        yield code_tokens

def tramp(gen, arg):
    g = gen(arg)
    return g

# 代码调用
tramp(tree_to_token_index,root_node)

参考链接: https://blog.csdn.net/ztf312/article/details/81296772

Logo

汇聚全球AI编程工具,助力开发者即刻编程。

更多推荐