废话不多说,直接上代码!
def get_current_path():
paths = sys.path
current_file = os.path.basename(__file__)
for path in paths:
try:
if current_file in os.listdir(path):
return path
break
except (FileExistsError,FileNotFoundError) as e:
return False;
网友评论