-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstr_split.py
More file actions
39 lines (29 loc) · 938 Bytes
/
str_split.py
File metadata and controls
39 lines (29 loc) · 938 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# -*- coding: utf-8 -*-
"""
Created on Wed Nov 29 08:54:57 2017
@author: tony
"""
'''字符串的split分割使用'''
s = '''001::aaa (1990)::Horror
002::bbb (1992)::Drama
003::ccc (1980)::Action|Drama|Thriller'''
c=0
ss= s.split('\n')
for x in ss:
k = x.split("::")
#===============================================================================
# print 'bianhao:', k[0],
# print 'name:', k[1][:-6],
# print 'year:', k[1][-5:-1]
#===============================================================================
lx=k[2].split("|")
i=0
for n in lx:
#===============================================================================
# print 'leixing:' + str(i), n
#===============================================================================
if n == 'Drama':
c+=1
print c,k[1][:-6]
i += 1
print c