\u5c06\u82f1\u6587\u5355\u8bcd\u9996\u5b57\u6bcd\u53d8\u6210\u5927\u5199\u662f\u975e\u5e38\u5e38\u7528\u7684\u6587\u672c\u64cd\u4f5c\uff0c\u4f7f\u7528capitalize\u65b9\u6cd5\u53ef\u4ee5\u5c06\u4e00\u4e2a\u82f1\u6587\u5355\u8bcd\u7684\u9996\u5b57\u6bcd\u53d8\u6210\u5927\u5199\u3002\u4f46\u5982\u4f55\u5c06\u4e00\u6bb5\u6587\u672c\u4e2d\u6240\u6709\u82f1\u6587\u5355\u8bcd\u7684\u9996\u5b57\u6bcd\u90fd\u53d8\u6210\u5927\u5199\u5462?\u6700\u5bb9\u6613\u60f3\u5230\u7684\u65b9\u6cd5\u662f\u5c06\u8fd9\u4e9b\u82f1\u6587\u5355\u8bcd\u62c6\u6210\u72ec\u7acb\u7684\u5355\u8bcd\uff0c\u7136\u540e\u5206\u522b\u4f7f\u7528capitalize\u65b9\u6cd5\u5c06\u8fd9\u4e9b\u82f1\u6587\u5355\u8bcd\u7684\u9996\u5b57\u6bcd\u53d8\u6210\u5927\u5199\uff0c\u7136\u540e\u518d\u5c06\u8fd9\u4e9b\u5355\u8bcd\u8fde\u63a5\u8d77\u6765\uff0c\u5b9e\u73b0\u4ee3\u7801\u5982\u4e0b\uff1a<\/p>\n
\r\ns = 'The weather is really nice today, very suitable for an outing.' \r\n \r\narr = s.split() \r\nfor i in range(0, len(arr)): \r\n arr[i] = arr[i].capitalize() \r\ns1 = \" \".join(arr) \r\nprint(s1) \r\n<\/pre>\n\u8fd0\u884c\u4ee3\u7801\u770b\u770b\u6548\u679c\uff1a<\/p>\n
\u4ece\u8fd9\u6bb5\u4ee3\u7801\u53ef\u4ee5\u770b\u51fa\uff0c\u4f7f\u7528\u4e863\u4e2a\u65b9\u6cd5\uff1asplit\u3001capitalize\u548cjoin\u3002\u5206\u522b\u7528\u6765\u62c6\u5206\u5b57\u7b26\u4e32;\u5c06\u82f1\u6587\u5355\u8bcd\u9996\u5b57\u6bcd\u8f6c\u6362\u4e3a\u5927\u5199;\u4f7f\u7528\u7279\u5b9a\u7684\u5206\u9694\u7b26(\u672c\u4f8b\u662f\u7a7a\u683c)\u5408\u5e76\u5217\u8868\u4e2d\u7684\u5b57\u7b26\u4e32\u3002<\/p>\n
\u4e0d\u8fc7\u8fd9\u6bb5\u4ee3\u7801\u597d\u9ebb\u70e6\uff0c\u6709\u6ca1\u6709\u66f4\u7b80\u5355\u7684\u65b9\u5f0f\u5462?\u5f53\u7136\u6709\uff0c\u94db\u94db\u94db!\u521a\u51fa\u9505\u7684\u4ee3\u7801\u6765\u4e86\uff1a<\/p>\n
s = 'The weather is really nice today, very suitable for an outing.' \r\nprint(\" \".join([word.capitalize() for word in s.split()])) # \u53ea\u7528\u4e86\u4e00\u884c\u4ee3\u7801 <\/pre>\n\u591f\u9177\u5427\uff0c\u8fd9\u91cc\u53ea\u7528\u4e86\u4e00\u884c\u4ee3\u7801\u3002\u5176\u5b9e\u8fd9\u884c\u4ee3\u7801\u4e0e\u524d\u9762\u7684\u5b9e\u73b0\u65b9\u6cd5\u6ca1\u6709\u672c\u8d28\u7684\u533a\u522b\uff0c\u53ea\u662f\u7528\u4e86Python\u4e2d\u901a\u8fc7for in\u8bed\u53e5\u751f\u6210\u5217\u8868\u7684\u65b9\u5f0f\uff0c\u5c06\u591a\u884c\u4ee3\u7801\u7b80\u5316\u6210\u4e86\u4e00\u884c\u4ee3\u7801\uff0cPython\u7b80\u76f4\u592a\u795e\u5947\u4e86\u3002\u5176\u5b9e\u554a\uff0c\u5982\u679c\u8981\u719f\u6089Python API\uff0c\u8fde\u4e00\u884c\u4ee3\u7801\u90fd\u4e0d\u7528\u5199\uff0c\u4e00\u4e2a\u65b9\u6cd5\u5c31\u89e3\u51b3\u4e86\uff0c\u8fd9\u5c31\u662fstring.capwords\u65b9\u6cd5\uff0c\u8be5\u65b9\u6cd5\u5c5e\u4e8estring\u6a21\u5757\uff0c\u6240\u4ee5\u9700\u8981\u5148\u5bfc\u5165string\u6a21\u5757\uff0c\u4ee3\u7801\u5982\u4e0b\uff1a<\/p>\n
import string \r\ns = 'The weather is really nice today, very suitable for an outing.' \r\nprint(string.capwords(s)) #\u5c06\u5b57\u7b26\u4e32\u4e2d\u6240\u6709\u5355\u8bcd\u9996\u5b57\u6bcd\u5927\u5199 <\/pre>\n\u770b\u770b\u7b80\u5355\u4e0d\uff0c\u522b\u5fd9\uff0c\u8fd8\u6ca1\u5b8c\u5462!capwords\u65b9\u6cd5\u7684\u9ed8\u8ba4\u5206\u9694\u7b26\u662f\u7a7a\u683c\uff0c\u5982\u679c\u8fd9\u4e9b\u82f1\u6587\u5355\u8bcd\u7528\u5176\u4ed6\u7b26\u53f7\u5206\u9694\uff0c\u5c31\u9700\u8981\u4f7f\u7528capwords\u65b9\u6cd5\u7684\u7b2c2\u4e2a\u53c2\u6570\u4e86\uff0c\u770b\u4e0b\u9762\u7684\u4f8b\u5b50\uff1a<\/p>\n
\r\nimport string \r\ns = 'The,weather,is,really,nice,today,very,suitable,for,an,outing.' \r\nprint(string.capwords(s, ',')) # \u7528\u9017\u53f7\u5206\u9694\u7684\u82f1\u6587\u5355\u8bcd <\/pre>\n\u8fd9\u6bb5\u4ee3\u7801\u4f7f\u7528capwords\u65b9\u6cd5\u5c06\u7531\u9017\u53f7(,)\u5206\u9694\u7684\u6240\u6709\u82f1\u6587\u5355\u8bcd\u7684\u9996\u5b57\u6bcd\u8f6c\u6362\u4e3a\u5927\u5199\u5b57\u6bcd\u3002\u8fd0\u884c\u7ed3\u679c\u5982\u4e0b\uff1a<\/p>\n
\r\nThe,Weather,Is,Really,Nice,Today,Very,Suitable,For,An,Outing. \r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"\u5c06\u82f1\u6587\u5355\u8bcd\u9996\u5b57\u6bcd\u53d8\u6210\u5927\u5199\u662f\u975e\u5e38\u5e38\u7528\u7684\u6587\u672c\u64cd\u4f5c\uff0c\u4f7f\u7528capitalize\u65b9\u6cd5\u53ef\u4ee5\u5c06\u4e00\u4e2a\u82f1\u6587\u5355\u8bcd\u7684\u9996\u5b57\u6bcd\u53d8\u6210\u5927\u5199\u3002 […]<\/p>\n","protected":false},"author":317,"featured_media":206651,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[55],"tags":[],"class_list":["post-211664","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-thread"],"acf":[],"_links":{"self":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/211664","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/users\/317"}],"replies":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/comments?post=211664"}],"version-history":[{"count":2,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/211664\/revisions"}],"predecessor-version":[{"id":211667,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/211664\/revisions\/211667"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media\/206651"}],"wp:attachment":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media?parent=211664"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/categories?post=211664"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/tags?post=211664"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}