我有以下代码:
Traceback (most recent call last):
File "<string>", line 1, in <module>
ModuleNotFoundError: No module named 'angelheap'
Error while executing Python code.
我要删除第一个元素,我想对其余元素进行排序 这就是我得到的:
x='10 0 17 5'
a = x.split(' ')
first = a.pop(0)
print(first)
print(a)
c = a.sort(key=int)
print(c)
根据此帖子Sort a List of string by Numeric Order,我们希望看到“无”,我希望看到['0','5','17']。
为什么它不起作用?
10
['0', '17', '5']
None
x='10 0 17 5'
a = x.split(' ')
first = a.pop(0)
print(first)
print(a)
c = a.sort(key=int)
print(c)
d = sorted(a)
print(d)
e = sorted(a.items())
print(e)
//
10
['0', '17', '5']
None
['0', '17', '5']
Traceback (most recent call last):
File "index.py", line 14, in <module>
e = sorted(a.items())
AttributeError: 'list' object has no attribute 'items'