解决Windows系统下Python不能使⽤export指令的困扰export是linux系统下的指令,在window系统下不能使⽤,很不⽅便,本⽂复现了⼀下export的功能。
问题描述:
'export' 不是内部或外部命令
新建exporttest.py,代码如下:
import argpar
import sys
from pathlib import Path
parr = argpar.ArgumentParr()
诚信让生活更美好作文
parr.add_argument("--path", type=str, default="")
parr.add_argument("--deletepath", type=str, default="")
args = parr.par_args()
# sys.path.append(r'newlib_path')
if __name__ == '__main__':
exportpath = eval(repr(args.path).replace('\\', '\\\\'))
exportpathlist=exportpath.split('AND')
# print(pathlist)
狗叫声汪汪汪# utable)
deletepath = eval(repr(args.deletepath).replace('\\', '\\\\'))
deletepathlist = deletepath.split('AND')
filepath=sys.prefix+'\Lib\site-packages\myExportPath.pth'
file = Path(filepath)
if ists():
# print("File doesn't exist, this code will first create one and then add the paths")
虎斑猫湖南风俗with file.open('w') as f:
for path in exportpathlist:
f.write(path)
f.write("\n")
existingPaths = ad_text()
existingPathslist = filter(None, existingPaths.split('\n'))
with file.open('w') as f: # 创建并写⼊。
for existingPath in existingPathslist:
deleteFlag=Fal
for path in deletepathlist:
if existingPath == path:
deleteFlag=True
break桌面小游戏
if deleteFlag==Fal:
f.write(existingPath)
f.write("\n")
existingPaths = ad_text()
print("The export paths are: \n"+existingPaths)
el:
# print("The file exists, this code will add the paths to the existing file")什么的自述作文
ad_text()
existingPathslist = filter(None,existingPaths.split('\n'))
with file.open('a') as f:
for path in exportpathlist:
existingFlag=Fal
for existingPath in existingPathslist:
if existingPath == path:
existingFlag=True
print("warning: the path "+path+" already exists")
print("warning: the path "+path+" already exists")
break
if existingFlag==Fal:
f.write(path)
中国最长的内流河f.write("\n")
existingPaths = ad_text()
existingPathslist = filter(None, existingPaths.split('\n'))
with file.open('w') as f:
for existingPath in existingPathslist:
deleteFlag = Fal
for path in deletepathlist:
if existingPath == path:
deleteFlag = True
break
if deleteFlag == Fal:
f.write(existingPath)
f.write("\n")
existingPaths = ad_text()
print("The export paths are: \n" + existingPaths)
# print(sys.path)
使⽤⽅法如下:
1、添加⼀条path
指令:
python exporttest.py --path XXXX #XXXX为你需要export的路径
⽰例:他作文
2、 添加多条path,path中间⽤AND连接
指令:
python exporttest.py --path XXXXANDXXXX #XXXX为你需要export的路径⽰例:
3、查看已经添加的path
指令:
python exporttest.py
⽰例:
4、删除⼀条path
指令:
python exporttest.py --deletepath XXXX #XXXX为你需要删除的路径⽰例:
5、删除多条path,同2,中间⽤AND连接