Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
238 views
in Technique[技术] by (71.8m points)

python - Splitting a person's name into forename and surname

ok so basically I am asking the question of their name I want this to be one input rather than Forename and Surname.

Now is there any way of splitting this name? and taking just the last word from the "Sentence" e.g.

name = "Thomas Winter"
print name.split() 

and what would be output is just "Winter"

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

You'll find that your key problem with this approach isn't a technical one, but a human one - different people write their names in different ways.

In fact, the terminology of "forename" and "surname" is itself flawed.

While many blended families use a hyphenated family name, such as Smith-Jones, there are some who just use both names separately, "Smith Jones" where both names are the family name.

Many european family names have multiple parts, such as "de Vere" and "van den Neiulaar". Sometimes these extras have important family history - for example, a prefix awarded by a king hundreds of years ago.

Side issue: I've capitalised these correctly for the people I'm referencing - "de" and "van den" don't get captial letters for some families, but do for others.

Conversely, many Asian cultures put the family name first, because the family is considered more important than the individual.

Last point - some people place great store in being "Junior" or "Senior" or "III" - and your code shouldn't treat those as the family name.

Also noting that there are a fair number of people who use a name that isn't the one bestowed by their parents, I've used the following scheme with some success:

Full Name (as normally written for addressing mail); Family Name; Known As (the name commonly used in conversation).

e.g:

Full Name: William Gates III; Family Name: Gates; Known As: Bill

Full Name: Soong Li; Family Name: Soong; Known As: Lisa


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...