温馨提示×

Python os函数中如何获取当前工作目录

小樊
90
2024-08-26 10:16:26
栏目: 编程语言
Python开发者专用服务器限时活动,0元免费领,库存有限,领完即止! 点击查看>>

在Python中,可以使用 os.getcwd() 函数来获取当前工作目录。示例如下:

import os

current_directory = os.getcwd()
print("Current working directory:", current_directory)

运行上面的代码将打印出当前工作目录的路径。

亿速云「云服务器」,即开即用、新一代英特尔至强铂金CPU、三副本存储NVMe SSD云盘,价格低至29元/月。点击查看>>

推荐阅读:python getcwd函数如何获取当前工作目录

0