TypeError object of type ‘type‘ has no len()—Python报错问题:
翻译过来是类型为“type”的TypeError对象没有len(),我报错的代码是:
https://blog.csdn.net/hanhanwanghaha宝藏女孩 欢迎您的关注!
欢迎关注微信公众号:宝藏女孩的成长日记
让这个可爱的宝藏女孩在努力的道路上与你一起同行!
如有转载,请注明出处(如不注明,盗者必究)
#coding=utf-8print("请输入一个字符串:")
a = input('')
#回文的长度至少为2
if len(str) < 2:print('请不要输入空字符串!')a = input('请重新输入一个字符串:')
b = reversed(list(a))
if list(b) == list(a):print(a,'是回文')
else:print(a,'不是回文')
运行结果:
将if len(a) < 2 里面的a错写成了python里面的内置函数str,我们将代码改回来,代码:
#coding=utf-8print("请输入一个字符串:")
a = input('')
#回文的长度至少为2
if len(a) < 2:print('请不要输入空字符串!')a = input('请重新输入一个字符串:')
b = reversed(list(a))
if list(b) == list(a):print(a,'是回文')
else:print(a,'不是回文')
现在就能正常运行了
https://blog.csdn.net/hanhanwanghaha宝藏女孩 欢迎您的关注!
欢迎关注微信公众号:宝藏女孩的成长日记
让这个可爱的宝藏女孩在努力的道路上与你一起同行!
如有转载,请注明出处(如不注明,盗者必究)
TypeError object of type ‘type‘ has no len()—Python报错问题:相关推荐
- python 报错 AttributeError: type object ‘datetime.datetime‘ has no attribute ‘datetime‘
python报错:type object 'datetime.datetime' has no attribute 'datetime' 描述:在第一个python程序里还未报错,第二个程序完全复制过 ...
- python报错:TypeError: cant multiply sequence by non-int of type float(bug)(csdn标题没法用英文引号,以后注意别搜引号)
python报错:TypeError: can't multiply sequence by non-int of type 'float' 注意:csdn标题没法用英文引号,以后注意别搜引号!!!! ...
- Python报错TypeError: ‘User‘ object is not iterable
Python报错TypeError: 'User' object is not iterable 原因 User对象是不可迭代的,我这里是因为User并不是list,所以是不可迭代的,所以不使用迭代即 ...
- Python报错TypeError: 'str' object is not callable
原文:http://blog.sina.com.cn/s/blog_71f3890901017rsh.html Python报错TypeError: 'str' object is not calla ...
- python报错 TypeError: an integer is required
问题描述: 在本地使用socket向NetAssist传送数据的时候,执行python文件后发现报出python 报错TypeError: an integer is required错误 代码: 1 ...
- Python更新数据库,解决转译字符与TypeError: XX format: a number is required, not str报错
在使用python更新数据库的时候出现了好多坑,一个个填完之后整理出了完备的代码: import MySQLdb#链接数据库的套路操作 db = MySQLdb.connect("local ...
- Python报错 TypeError: Descriptors cannot not be created directly
Python报错TypeError: Descriptors cannot not be created directly 具体错误: TypeError: Descriptors cannot no ...
- Python报错TypeError: Descriptors cannot not be created directly
Python报错TypeError: Descriptors cannot not be created directly 具体错误: TypeError: Descriptors cannot no ...
- python报错TypeError: must be str, not int
python报错TypeError: must be str, not int 字符串拼接一个整型变量报错,代码如下 for i in range(1,586):res = 'test' + i 报错 ...
最新文章
- 下载插件(贪心算法)
- android自定义tab下划线变大,Android开发之设置TabLayout下方下划线的宽度
- 【建站系列教程】2.2、fiddler手机抓包教程
- 研发项目进度管理软件正式上线
- OpenGL polygonsmooth多边形平滑的实例
- spring mvc拆分_Spring集成–强大的拆分器聚合器
- python 压力测试小 demo
- Qemu 简述 | 转
- C# CharacterToBinary 将类似2进制字符串 10010110111 转换为数值型源码
- 如何简单描述java中的代理模式
- JPush极光推送的原理
- 干货!电商小白入门电商运营必看
- 唯物主义观点有哪些_唯物主义的观点及方法论有哪些?
- 【支付】网络支付-支付网关模式与虚拟账户模式
- 同宇新材冲刺深交所:年营收9.47亿 张驰与苏世国为实控人
- Python:绘制数学图形(2)
- 改进YOLOv7系列:首发结合最新Centralized Feature Pyramid集中特征金字塔,通过COCO数据集验证强势涨点
- linux禁止root用户su,Linux 禁止普通用户su到root
- python turtle绘图蟒蛇
- RIO——健壮的IO包
热门文章
- linux svn 指定端口号,linux(Ubuntu)搭建Subversion服务器+修改svn端口号
- matlab 一维 平滑,一维加噪信号的平滑处理(3)
- 背景图层和普通图层的区别_图层样式(一)—高级混合选项
- ThreadLocal初识
- Spring Boot——Redis安装配置与应用整合
- android ble蓝牙接收不到数据_Android蓝牙4.0 Ble读写数据详解 -2
- C语言程序设计基础练习题
- Matlab guide菜单+快捷菜单的使用
- (STL,set,priority_queue)丑数
- jsp中java代码无效_来杯咖啡,教你如何优雅的在java中统计代码块耗时