Replace the contents between two characters


Open = F ( "1.xml", 'R & lt +', encoding = 'UTF-. 8')
all_the_lines f.readlines = ()
# note pointer problems
f.seek (0) # pointer location is the beginning
f.truncate (0) Clear file #

# Print (f.tell ())
for in all_the_lines Line:

A = "/ Data / Voice /"
IF in Line A:
SS = line.split (A) [. 1]
Line = line.replace (SS, 'add # \ n object + "\ n") and the lower register for'

Line = line.replace (a, '')
Line = line.replace ( "<the Input>", '')
Line = line.replace ( "</ the Input>", '')

f.write (Line)
f.close ()

<? xml Version = "1.0" encoding = "UTF-8"?>
<Executions>
<Execution name = "VoiceCase_Lite-S1_Static_online" of the type = "Voice">
<Turn>
<the Input> /data/voice/20190725_035326_2_voice_in_dump.wav < / the Input>
<Action> Action: // scenemode / rain_mode </ Action>
<ASR> open rain mode </ ASR>
<Scene> windows / sunroof / air conditioning off / vehicle stationary </ Scene>
</ Turn>
<Turn >
<the Input> /data/voice/20190725_035330_3_voice_in_dump.wav </ the Input>
<the Action> the Action: // carcontrol / up_air_temperature </ the Action>
<the ASR> increase the air temperature </ the ASR>
<Scene> windows / sunroof / air-conditioning Close / vehicle stationary </ Scene>
</ Turn>
<Turn>
<Input>/data/voice/20190725_035335_4_voice_in_dump.wav</Input>
<Action>Action://scenemode/starry_mode</Action>
<ASR>打开星空模式</ASR>
<Scene> windows / sunroof / air conditioning off / vehicle stationary </ Scene>
</ Turn>
<Turn>
<the Input> /data/voice/20190725_035339_5_voice_in_dump.wav </ the Input>
<Action> Action: // carcontrol / down_air_temperature < / the Action>
<the ASR> point temperature decreases, the temperature is lowered a little </ the ASR>
<Scene> windows / sunroof / off air conditioning / vehicle stationary </ Scene>
</ Turn>
<Turn>
<the Input> / Data / Voice / 20190725_035343_6_voice_in_dump.wav </ the Input>
<the Action> the Action: // carcontrol / set_air_temperature </ the Action>
<the ASR> the temperature was raised to 26 degrees, the temperature was raised to 26 degrees </ the ASR>
<Scene> window / sunroof / off air conditioning / vehicle stationary </ Scene>
</ Turn>

</Execution>
</Executions>



Guess you like

Origin www.cnblogs.com/wyx1990/p/12006267.html