a={"one":1, "two":2, "three":3}
a["one"]
a={"a":1, "b":3, "c":5, "d":7}
b=[(x, a[x]) for x in a]
b
a는 dictionary(dic)니깐 변수값 x는 a dic의 key값만
가지게(가질수있게) 된다!?
고로 x에는 "a","b"등의 key만 오게되고 a\[x\] 에는
a dic의 key인 "a"가 오며 표현하면 a\["a"\]는
즉, value 값인 1이 나오게 된다!
l="""Batman.The.Animated.Series.S01E01."""
l2="1080p.BluRay.DTSHD-MA.H.264-BTN"
l3="i like programming, i "
a="Batman.The.Animated.Series.S01E01.The.Cat.and.the.Claw.Part.One.1080p.BluRay.DTSHD-MA.H.264-BTN"
print(a[0:7])
print(len(l),len(l2),len(l3))
print(a.strip('.'))
Batman.The.Animated.Series.S01E01.The.Cat.and.the.Claw.Part.One.1080p.BluRay.DTSHD-MA.H.264-BTN
Batman The Animated Series 15 - The Cat and the Claw
옵션에서 '.'과 ' '(스페이스)를 없는셈치고 비교하는 연산을 하면
좋을텐데.. 어떻게 할수있을까? - 밑에답!
l4="i like programming, i like swimming."
a="abcabcabc"
b="abcabcabc2"
c="abcabc"
print(l4.find('like'))
print(l4.rfind('like'))
print(l4.index('like'))
print(l4.rindex('like'))
print(l4.startswith('progr', 7))
print(l4.endswith('swimming.', 0, 99))
if c.startswith(a):
print(c.startswith(a))
else:
print(c.startswith(a))
print('<>abc<><><>'.strip('<>'))
u = ' spam and ham '
print(u.replace(' ',''))
t = u.split()
print(''.join(t))
print(':'.join(t))
print ('\n'.join(t))
import re
text = u'010-1566#7152'
parse = re.sub('[-=.#/?:$}]', '', text)
print (parse)
print(u'\u4000\u4001abc\u4000'.strip(u'\u4000'))
s=" #$ abc.CBA.abc #$% &"
print(s.replace('#$','%').replace('%',''))
ss=re.sub('[ #$%&.]','', s)
ss=re.sub('cba','jjj',re.sub('abc','cba', ss))
print(ss)
s='abcCBAdef'
a=s[3:-3]
print(a in s)
print(s,a,b)
import os
import re
path = "L:\ANI\Batman The Animated Series"
flist = os.listdir(path)
flistmkv = [file for file in flist if file.endswith('.mkv')]
flistre = [file.replace('.','') for file in flistmkv]
pathsub = "D:\Downloads\Subtiltle relation\Batman+The+Animated+Series"
sublist = os.listdir(pathsub)
subre = [file.replace(' ', '') for file in sublist]
print(subre)
import os
import re
path = "L:\ANI\Batman The Animated Series"
pathsub = "D:\Downloads\Subtiltle relation\Batman+The+Animated+Series"
flist = os.listdir(path)
sublist = os.listdir(pathsub)
flistre = []
subre = []
for i in flist:
if i.endswith('.mkv'):
i=re.sub('[ .]', '', i)
i=i[29:-30]
flistre.append(i)
print(flistre)
f=open("aaa.txt", 'w')
f.write('ddddddjjjjjj')
f.close()
print (f)
f=open("aaa.txt")
for file in f:
print(file)
print(f)
a= "'"
print (a)
a="Two face Part One Part Two.smi"
b=a.replace('PartTwo', 'PartII')
c=re.sub('PartTwo','PartII',a)
f = a.replace(' ','').replace('.', '').replace('PartTwo','PartII').replace('PartOne','')
print(a)
print(b)
print(c)
print(f)
a="Batman.The.Animated.Series.S01E58.The.Demons.Quest.Part.Two.1080p.BluRay.DTSHD-MA.H.264-BTN.mkv"
b="Batman.The.Animated.Series.S01E51.Robins.Reckoning.Part.One.1080p.BluRay.DTSHD-MA.H.264-BTN.mkv"
c="Batman The Animated Series 10 - Two Face Part I.smi"
d=a.replace('[.-]','')
print(a[34:-35])
print(b[34:-35])
print(c[32:-4])
print(d)