我有这个:
Warning: include(/share/HDA_DATA/Web/application/views/errors/html/error_php.php): failed to open stream: No such file or directory in /share/HDA_DATA/Web/system/core/Exceptions.php on line 269
Warning: include(): Failed opening '/share/HDA_DATA/Web/application/views/errors/html/error_php.php' for inclusion (include_path='.:/etc/config/php') in /share/HDA_DATA/Web/system/core/Exceptions.php on line 269
Warning: include(/share/HDA_DATA/Web/application/views/errors/html/error_php.php): failed to open stream: No such file or directory in /share/HDA_DATA/Web/system/core/Exceptions.php on line 269
Warning: include(): Failed opening '/share/HDA_DATA/Web/application/views/errors/html/error_php.php' for inclusion (include_path='.:/etc/config/php') in /share/HDA_DATA/Web/system/core/Exceptions.php on line 269
但它仍然没有使第一个字母大写。
答案 0 :(得分:1)
.upper()
返回一个新字符串,因为字符串是不可变数据类型。您应该将返回值设置为变量。
如果您只想将第一个字母设为大写,则可以使用.capitalize
而不是.upper
。
>>> word = raw_input("enter a word")
>>> word = word.capitalize()
请注意.capitalize
将其余字符变为小写。如果您不希望它发生,请使用[0].upper()
:
word = word[0].upper() + word[1:]