在python中的格式化方法中使用大写方法

问题描述

string_ = "hello world"
print("{0[1].capitalize()} {0[0].capitalize()}".format(string_.split(" ")))

运行这个我得到

AttributeError: 'str' object has no attribute 'capitalize()'

请告诉我哪里出了问题,因为字符串方法中有大写方法

dir(string_)
Out[108]: 
[...
 'capitalize',...]

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)