Last active
May 22, 2017 14:33
-
-
Save leopard627/79465b0e3879d6cdc4c47fa7deb32193 to your computer and use it in GitHub Desktop.
마지막 테일값에 쓰레기값이 붙습니다만 . . .
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
a = ['Hello', 'Sydney', 'I', 'Am'] | |
b = [1, 2, 3, -1212.022, 5523, 232441, 1000] | |
# way 1 방법1 | |
with open("foo.txt", "w") as f: | |
map(lambda var: f.write(str(var)) if var == b[-1:][0] else f.write(str(var) + " "), b) | |
# way 2 방법2 | |
with open("foo.txt", "w") as f: | |
f.write(" ".join(map(str, a))) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
결과값은 1 2 3 -1212.022 5523 232441 1000" " 마지막에 스페이스 하나 붙습니다.
---> 잡았습니다
---> 방법 1의 가독성은 최악이네요
---> 방법 2가 더 간결하고 좋아보이네요