ls='python'
li=list(ls)
flag=0
p=list(set(li))
q=p.sort(key=li.index)
print(q)
print(type(q))
for i in q:
print(i)
错误原因:sort无返回值,所以导致了q 是NONE类型
runfile('C:/Users/hp/.spyder-py3/temp.py', wdir='C:/Users/hp/.spyder-py3')
None
<class 'NoneType'>
Traceback (most recent call last):
File "C:\Users\hp\.spyder-py3\temp.py", line 8, in <module>
for i in q:
TypeError: 'NoneType' object is not iterable