def getMSTestPath(testPath):
dllFilePath = r'C:\Users\bgbesase\Documents\Brent\Code\Visual Studio'
msTestFilePath = []
dllConvert = []
full_dllPath = []
for r, d, f in os.walk(testPath):
for files in f:
if files.endswith('.UnitTests.vbproj'):
#testPath = os.path.abspath(files)
testPath = files.strip('.vbproj')
msTestFilePath.append(testPath)
#print testPath
#print msTestFilePath
for lines in msTestFilePath:
ss = lines.replace(r'.', r'-')
#print ss
dllConvert.append(ss)
for lines in testPath:
dllFilePath = dllFilePath + '' + lines + '\bin\Debug' + '.dll' + '\n'
full_dllPath.append(dllFilePath)
print full_dllPath
msTestFilePath = [str(value[1]) for value in msTestFilePath]
return msTestFilePath
testPath = [blah.APDS.UnitTests
blah.DatabaseAPI.UnitTests
blah.DataManagement.UnitTests
blah.FormControls.UnitTests ]
ss = [ blah-APDS-UnitTests
blah-DatabaseAPI-UnitTests
blah-DataManagement-UnitTests
blah-FormControls-UnitTests ]
我需要遍历路径,首先:获取以.UnitTests
结尾的所有文件,并将它们作为列表testPath
返回。然后,我必须将所有的.
转换成-
,并将该列表作为ss返回。你知道吗
这就是我被卡住的地方,我需要经过一个循环,因为testPath
中有很多元组,我需要添加'dllFilePath+testPath+'\bin\Debug\'+ss+'.dll'
然而,我不能让它工作,我不知道为什么,输出只是一些废话,:( 谢谢你的帮助。你知道吗
不要使用
.strip()
;它将其参数视为字符集,而不是特定的序列。你知道吗因此,您正在删除集合
{'.', 'v', 'b', 'p', 'r', 'o', 'j'}
中的所有字符,而且删除的字符远远超出您的想象:使用字符串切片:
或者使用
os.path.splitext()
:演示:
相关问题 更多 >
编程相关推荐