python的字符串截取
str = ‘
0123456789’
print str[0:3]
print str[:]
print str[6:]
print str[:-3]
print str[2]
print str[-1]
print str[::-1]
print str[-3:-1]
print str[-3:]
print str[:-5:-3]
text
[3:4]
012
0123456789
6789
0123456
2
9
9876543210
78
789
96
Python 拼接字符串的几种方式
str_name1
= 'To'
str_name2
= 'ny'
str_name
= str_name1
+ str_name2
print(str_name
)
项目相关
print('hello')
print(opt
.input_video
)
input_Name
=opt
.input_video
gang
="\\"
videoname
=input_Name
[input_Name
.rfind
(gang
)+1:]
print(videoname
.find
('.'))
index
=videoname
.find
('.')
print(videoname
)
video_pre
=videoname
[0:index
]
print(video_pre
)
last
=video_pre
[-1]
print(last
)
suffix
="_det.mp4"
frame_suffix
="_frame"
whole_frame_save
=video_pre
+frame_suffix
whole_Video_Name
=video_pre
+suffix
txt_sufficx
="_det.txt"
whole_txt_Path
=video_pre
+txt_sufficx
print(whole_Video_Name
)
print(whole_frame_save
)
print(whole_txt_Path
)
if last
=="1":
txt
="H:\listen\calm\calm_txt\\"+whole_txt_Path
if last
=="2":
txt
="H:\listen\hurry\hurry_txt\\"+whole_txt_Path
print(txt
)
print('world')
if opt
.output_format
== 'video':
if last
=="1":
result_root2
="H:\listen\calm\calm_det_video"
if last
=="2":
result_root2
="H:\listen\hurry\hurry_det_video"
else:
result_root2
="H:\Tracking\Towards-Realtime-MOT-master\Towards-Realtime-MOT-master"
output_video_path
= osp
.join
(result_root2
, whole_Video_Name
)
cmd_str
= 'ffmpeg -f image2 -i {}/%05d.jpg -c:v copy {}'.format(osp
.join
(result_root
, whole_frame_save
), output_video_path
)
os
.system
(cmd_str
)
hello
H
:\listen\calm\calm_video\1_1
.mp4
3
1_1
.mp4
1_1
1
1_1_det
.mp4
1_1_frame
1_1_det
.txt
H
:\listen\calm\calm_txt\1_1_det
.txt
world