- 博客(1)
- 收藏
- 关注
原创 Python 将一句话按空格仅输出首个单词
def first_word(text): index = text.find(" ") return text[:index] if index != -1 else text first_word("Hello world") == "Hello" first_word("a word") == "a" first_word("hi") == "hi" text.find(" ")功能被遗忘,导致使用了弯弯绕绕才做出来 原始代码: a="a word" d=[] for ...
2021-10-21 21:55:03
669
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人