jorislalala 2021-10-17 01:20 采纳率: 100%
浏览 62
已结题

Python字符串相加


weatherToday = "sunny"
weatherTomorrow = "cloudy"
weatherForecast = "Today is going to be " + weatherToday + " and tomorrow will be " + weatherTomorrow + "."
currentTemp = 25
wetaherForecast = weatherForecast + " The current temperature is {:d}.".format(currentTemp)
print(weatherForecast)

为什么这个得出来的不是Today is going to be sunny and tomorrow will be cloudy. The current temperature is 25. 而是Today is going to be sunny and tomorrow will be cloudy.

img

  • 写回答

2条回答 默认 最新

  • 关注

    后面那条字符串拼接最后不是赋给了weatherForecast,而是赋值给了wetaherForecast,也就是说你出现了拼写错误,打印的还是上面的拼接结果
    有帮助望采纳~

    img

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

问题事件

  • 系统已结题 10月25日
  • 已采纳回答 10月17日
  • 创建了问题 10月17日

悬赏问题

  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测