python getcwd函数在不同Python版本中的差异

   2024-10-01 8100
核心提示:在Python 2中,getcwd()函数是通过os模块调用的,用法如下:import oscurrent_dir = os.getcwd()print(current_dir)在Python 3中

在Python 2中,getcwd()函数是通过os模块调用的,用法如下:

import oscurrent_dir = os.getcwd()print(current_dir)

在Python 3中,getcwd()函数已经移到了os模块的path子模块中,用法如下:

import oscurrent_dir = os.path.abspath(os.path.curdir)print(current_dir)

因此,在Python 2和Python 3中调用getcwd()函数的方式略有不同,需要注意这两个版本之间的差异。

 
举报打赏
 
更多>同类物流大全
推荐图文
推荐物流大全
点击排行

网站首页  |  关于我们  |  联系方式网站留言    |  赣ICP备2021007278号