Skip to content

Instantly share code, notes, and snippets.

@leopard627
Last active May 22, 2017 14:33
Show Gist options
  • Save leopard627/79465b0e3879d6cdc4c47fa7deb32193 to your computer and use it in GitHub Desktop.
Save leopard627/79465b0e3879d6cdc4c47fa7deb32193 to your computer and use it in GitHub Desktop.
마지막 테일값에 쓰레기값이 붙습니다만 . . .
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)))
@leopard627
Copy link
Author

leopard627 commented May 22, 2017

결과값은 1 2 3 -1212.022 5523 232441 1000" " 마지막에 스페이스 하나 붙습니다.

---> 잡았습니다
---> 방법 1의 가독성은 최악이네요
---> 방법 2가 더 간결하고 좋아보이네요

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment