题目:Write a function that takes a string as input and returns the string reversed. 写一个函数,它的输入是一个string,返回值为反转后的字符串。
分析:这不是python中的字符串反转? str[::-1]就可以了呀~

PS:list内元素的反转用 list.reverse()即可。
思路2:或者新建一个字符串,将原字符串从右向左逐位赋值。


题目:Write a function that takes a string as input and returns the string reversed. 写一个函数,它的输入是一个string,返回值为反转后的字符串。
分析:这不是python中的字符串反转? str[::-1]就可以了呀~
PS:list内元素的反转用 list.reverse()即可。
思路2:或者新建一个字符串,将原字符串从右向左逐位赋值。
本文标题:344. Reverse String python3
本文链接:https://www.haomeiwen.com/subject/kmmxhqtx.html
网友评论