python中的os基本使用

import json,os,sys

# with open("") as f:
#     print("file is open```")
thispath = os.getcwd()
print("this path is :",thispath)# 父目录,F:\stbPython

sysargv = sys.argv[0]
syspath = sys.path[0]
print("sys argv is :",sysargv)# f:\stbPython\2018-11-14filejson\file.py
print("sys path is :",syspath)# f:\stbPython\2018-11-14filejson

allpath = os.path.join(syspath,"te.json")
print("allpath is :",allpath)
print("exists is :",os.path.exists(allpath))

输出以下数据:

this path is : F:\stbPython
sys argv is : f:\stbPython\2018-11-14filejson\file.py
sys path is : f:\stbPython\2018-11-14filejson
allpath is : f:\stbPython\2018-11-14filejson\te.json
exists is : True

你可能感兴趣的:(python中的os基本使用)