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

Python实现字符串转大写时出现语法错误,求错误排查

问题排查:字符串转大写的语法错误

你的代码里的语法错误出在最后一行:

print =(result)

这里多写了一个=号,导致Python把这行识别为试图给内置函数print赋值,而不是调用print函数输出内容。

正确的写法应该去掉多余的=,直接调用print函数:

sentence = "Especially in electronic communications, writing in all caps is equivalent to yelling."

result = sentence.upper()
print(result)

运行修正后的代码,就能正常输出转成大写的字符串了。

内容的提问来源于stack exchange,提问作者Reyan-droid

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.21 12:54:21