大佬帮忙看下错误原因
str1 = input('输入你要找的字符串:')length = len(str1)
for i in range(length-4):
if str1.islower():
if str1.isupper() and str1.isupper() and str1.isupper() and \
str1.isupper() and str1.isupper() and str1.isupper():
if str1.isupper() == False and str1.isupper() == False:
print(str,end = '')
Traceback (most recent call last):
File "G:\phthon\练习\p20-2.py", line 9, in <module>
print(str,end = '')
TypeError: 'type' object is not subscriptable
这个报错是什么原因哇 第 9 行,str1 你写成 str 了
这个报错的意思就是你将不能进行索引的对象进行了索引
将 print 这一行代码 str 改成 str1 即可,参考代码:
str1 = input('输入你要找的字符串:')
length = len(str1)
for i in range(length-4):
if str1.islower():
if str1.isupper() and str1.isupper() and str1.isupper() and \
str1.isupper() and str1.isupper() and str1.isupper():
if str1.isupper() == False and str1.isupper() == False:
print(str1,end = '')
可能是因为你拷论坛的代码,论坛会吧 [ i] 吞了变成斜体
页:
[1]