python getcwd函数在区分Python版本中的差异
在Python 2中,getcwd()函数是通过os模块调用的,用法以下:
import os
current_dir = os.getcwd()
print(current_dir)
在Python 3中,getcwd()函数已移到了os模块的path子模块中,用法以下:
import os
current_dir = os.path.abspath(os.path.curdir)
print(current_dir)
因此,在Python 2和Python 3中调用getcwd()函数的方式略有区分,需要注意这两个版本之间的差异。
TikTok千粉号购买平台:https://tiktokusername.com/
TOP