我有一个嵌套列表,我正在尝试将所有标题大写(每个嵌套列表中的第三个元素,即红衣主教 Richelieu 等)。
似乎无法理解正确的方法。我认为替换会起作用,但出现错误:TypeError: replace() argument 2 must be str, not 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]