python - TypeError:一元+的错误操作数类型:'str'当我认为代码正确时
问题描述
character_age = "13"
character_name = "lado"
print( + character_name + " really like coding")
print( " but she didnt learn to type until " + character_age + " years old. ")
当出现错误时,我试图在 python 中学习变量
PS D:\freecodecamp> & C:/Users/admin/AppData/Local/Programs/Python/Python39/python.exe d:/freecodecamp/2.py
Traceback (most recent call last):
File "d:\freecodecamp\2.py", line 6, in <module>
print(+_character_name+ " really like coding, ")
TypeError: bad operand type for unary +: 'str'
解决方案
+
您的第一个打印声明中有一个额外的内容。用这个:print(character_name + " really like coding")
推荐阅读
- c# - Nuke 和更新 nuspec 文件
- php - 如何从检索数据库值中设置cookie并将其发送到php中的另一个页面
- sql-server - SQL Server:限制数据范围
- java - 有没有办法在 Java 正则表达式中包含 DOT 但不包含双整数?
- java - Firebase:无法将 java.lang.String 类型的对象转换为 com.example.g.Model.Cart 类型
- javascript - 使用快速把手为简单的节点 webapp 传递数据
- multithreading - LabVIEW如何处理多处理和多线程?
- python - 张量输出keras上的处理
- sql - SQL WHERE 子句性能问题 AX2012R3
- email - 从 php 邮件发送时 Godaddy 电子邮件转发器不起作用