我有以下词典:
In [37]: print(paths)
{'definition': ['dirname', 'basename'],
'condition': ['isdir', 'isfile', 'islink', 'isabs', 'ismount', 'exists', 'lexists'],
'get': ['getatime', 'getctime', 'getmtime', 'getsize'],
'split': ['split', 'splitdrive', 'splitext', 'join', 'normcase'],
'expand': ['expanduser', 'expandvars'],
'same': ['samefile', 'sameopenfile', 'samestat'],
'path': ['abspath', 'commonpath', 'defpath', 'genericpath', 'normpath', 'pathsep', 'realpath', 'relpath']}
我想要的结果是path_list
:
In [38]: path_list = []
...: for v in paths.values():
...: path_list.append(v)
In [42]: print(path_list)
['dirname', 'basename', 'isdir', 'isfile', 'islink', 'isabs', 'ismount', 'exists', 'lexists', 'getatime', 'getctime', 'getmtime', 'getsize', 'split', 'splitdrive', 'splitext', 'join', 'normcase', 'expanduser', 'expandvars', 'samefile', 'sameopenfile', 'samestat', 'abspath', 'commonpath', 'defpath', 'genericpath', 'normpath', 'pathsep', 'realpath', 'relpath']
我尝试使用内联代码解决问题。
In [43]: [ v for v in paths.values()]
Out[43]:
[['dirname', 'basename'],
['isdir', 'isfile', 'islink', 'isabs', 'ismount', 'exists', 'lexists'],
['getatime', 'getctime', 'getmtime', 'getsize'],
['split', 'splitdrive', 'splitext', 'join', 'normcase'],
['expanduser', 'expandvars'],
['samefile', 'sameopenfile', 'samestat'],
['abspath',
'commonpath',
'defpath',
'genericpath',
'normpath',
'pathsep',
'realpath',
'relpath']]
它没有产生我的结果。
如何完成它?