打印不带模块前缀的类类型

2024-06-26 10:10:21 发布

您现在位置:Python中文网/ 问答频道 /正文

我有一堆类类型(派生自type)。当我把它们打印出来的时候,我会得到这样的东西:

...
<class 'Default.new_templates.NewSnippetCommand'>
<class 'Default.new_templates.NewSyntaxCommand'>
<class 'Default.pane.ClosePaneCommand'>
<class 'Default.pane.FocusNeighboringGroup'>
<class 'Default.pane.MoveToNeighboringGroup'>
<class 'Default.pane.NewPaneCommand'>
<class 'Default.pane.SetMaxColumns'>
...

我想打印:

...
NewSnippetCommand
NewSyntaxCommand
ClosePaneCommand
FocusNeighboringGroup
MoveToNeighboringGroup
NewPaneCommand
SetMaxColumns
...

我怎样才能到达类名部分而忽略模块部分呢?你知道吗


Tags: default类型newtypetemplatesclass我会pane