在嵌套列表中将字符串转换为标题大小写

时间:2018-03-06 17:22:06

标签: python python-3.x replace title-case

我有一个嵌套列表,我试图大写所有标题(每个嵌套列表中的第三个元素,即基数richelieu等)。

似乎无法绕过正确的方法。我认为替换会起作用,但我收到错误:TypeError:replace()参数2必须是str,而不是builtin_function_or_method

下面 - 嵌套列表,然后我尝试替换。我很感激任何帮助,以了解我做错了什么!

    [['j234hg', '19 October 1969', 'court scene with cardinal richelieu'], ['d45j5jkd', '28 December 1969', 'THE ROYAL PHILHARMONIC ORCHESTRA GOES TO THE BATHROOM'], ['s4k5jk', '8 December 1970', 'crossing the atlantic on a tricycle'], ['zd7u4h', '19 October 1969', 'Bicycle Repair Man'], ['f983', '22 December 1970', 'Royal Episode 13 (or: The Queen Will Be Watching)'], ['j8s74', '15 September 1970', 'THE SEMAPHORE VERSION OF WUTHERING HEIGHTS'], ['n4j6l3j', '7 December 1972', 'Mr. Pither']]    

    records_list = [[x.replace(i[2], i[2].title) for x in i] for i in records_list]

0 个答案:

没有答案