变成列表(可变)操作后,再变成字符串(不可变)
"""
将英文语句进行反转
How are you -> you are How
"""
string = "How are you"
#
string_list = string.split(" ")
string_list = string_list[::-1]
rev_string = " ".join(string_list)
print(rev_string)
运行结果
you are How
变成列表(可变)操作后,再变成字符串(不可变)
"""
将英文语句进行反转
How are you -> you are How
"""
string = "How are you"
#
string_list = string.split(" ")
string_list = string_list[::-1]
rev_string = " ".join(string_list)
print(rev_string)
运行结果
you are How