48. ここが便利だよPython3
内包表記
>>> a = ["知ってる?", "知らない", "ミストルティンキック"]
>>> b = ["キックじゃない", "知ってる?", "知らない"]
>>> {x for x in a + b}
{'知らない', 'ミストルティンキック', '知ってる?', 'キックじゃない'}
>>>
48
49. ここが便利だよPython3
内包表記
>>> a = ["知ってる?", "知らない", "ミストルティンキック"]
>>> b = ["キックじゃない", "知ってる?", "知らない"]
>>> {x for x in a + b}
{'知らない', 'ミストルティンキック', '知ってる?', 'キックじゃない'}
>>>
集合も内包表記出来る!
49
52. ここが便利だよPython3
複数with文
Python2.x
with open("in.txt") as infile:
with open("out.txt", "w") as outfile:
outfile.write(infile.read())
Python3.x
with open("in.txt") as infile, open("out.txt", "w") as outfile:
outfile.write(infile.read())
52