Benefits of os.path.splitext over regular .split?

前端 未结 11 973
独厮守ぢ
独厮守ぢ 2020-12-08 13:16

In this other question, the votes clearly show that the os.path.splitext function is preferred over the simple .split(\'.\')[-1] string manipulatio

11条回答
  •  误落风尘
    2020-12-08 13:49

    A clearly defined and documented method to get the file extension would always be preferred over splitting a string willy nilly because that method would be more fragile for various reasons.

    Edit: This is not language specific.

提交回复
热议问题