Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

string_to_hump.md 里的python代码似乎可以写得更简单一些 #18

Open
nalzok opened this issue Jul 5, 2016 · 4 comments
Open

Comments

@nalzok
Copy link

nalzok commented Jul 5, 2016

比如这样:

#! /usr/bin/env python

print "Please input a name:"
snake_case = raw_input()
camelCase = []
for ch in snake_case.split("_"):
    camelCase.append(ch.title())
print "".join(camelCase)

@nalzok
Copy link
Author

nalzok commented Jul 5, 2016

这个似乎更短……

#! /usr/bin/env python

print "Please input a name:"
print "".join([ch.title() for ch in raw_input().split("_")])

——如果忽略可读性的话

@qiwsir
Copy link
Owner

qiwsir commented Jul 7, 2016

yes. you are right.

@qiwsir
Copy link
Owner

qiwsir commented Jul 19, 2016

good. thank you

2016-07-05 21:54 GMT+08:00 sunqingyao [email protected]:

这个似乎更短……

#! /usr/bin/env python

print "Please input a name:"
print "".join([ch.title() for ch in raw_input().split("_")])


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
#18 (comment),
or mute the thread
https://github.com/notifications/unsubscribe/ADel60rzDr7SBy5GDJ-cPf8_sBuztmXjks5qSmIQgaJpZM4JFH9i
.

QiWei

@nalzok
Copy link
Author

nalzok commented Jul 19, 2016

You're welcome. BTW, I didn't know what's a "generator" one week ago:

print ''.join(c.title() for c in raw_input('Please input a name:').split('_'))

Now I suppose this is the shortest version one can ever write.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants