You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

编写Brainfuck解释器遇报错:TypeError: chr() takes no keyword arguments

问题解决
  • 报错根源:你写的print(chr(int(stack[stack_pointer]),end=""))里,把end=""错放到了chr()的参数列表里。chr()函数只接受一个位置参数,不支持任何关键字参数,所以触发了TypeError。
  • 修正代码:把end=""移到chr()的括号外面,作为print()的参数:
print(chr(int(stack[stack_pointer])), end="")
  • 补充:你贴的,指令相关代码逻辑没问题,不用修改,问题完全出在输出语句的括号位置错误上。

内容的提问来源于stack exchange,提问作者Tommmaso44

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.21 16:58:59