新更新:
我有一个包含以下这些行的文本文件。
1.large -if D:/Dolby_Harmanious_kit/Dolby_Atmos_for_Sound_Bar_Products_SIDK/Test_Materials/Test_Signals/upmix_multitone/upmix_multitone_c/truehd/upmix_multitone_c_6ch_to_8ch.mlp -of out_dut.wav
2.large -if D:/Dolby_Harmanious_kit/Dolby_Atmos_for_Sound_Bar_Products_SIDK/Test_Materials/Test_Signals/upmix_multitone/upmix_multitone_l/truehd/upmix_multitone_l_6ch_to_8ch.mlp -of out_dut.wav
3.large -if D:/Dolby_Harmanious_kit/Dolby_Atmos_for_Sound_Bar_Products_SIDK/Test_Materials/Test_Signals/upmix_multitone/upmix_multitone_lfe/truehd/upmix_multitone_lfe_6ch_to_8ch.mlp -of out_dut.wav
在此我需要删除路径
“D:/ Dolby_Harmanious_kit / Dolby_Atmos_for_Sound_Bar_Products_SIDK / Test_Materials / Test_Signals / upmix_multitone / upmix_multitone_c / truehd /”就像我拥有的不同路径一样。 你能指导我吗?
答案 0 :(得分:2)
import re
test="y1.0 -iE:\CIDK\DDP\Test_Materials\Test_Signals\ITAF_Tests\acmod\LFE7.ec3 -19.wav"
resultat = re.sub('E:.*\\\\','',test)
print( resultat )
使用行读取编辑:
with open('filetest') as f:
for ligne in f:
print(re.sub('E:.*\\\\','',ligne).rstrip('\n'))