变更
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
# 序列的切片实践
|
||||
my_str = "万过薪月,员序程马黑来,nohtyp学"
|
||||
# 字符串整体倒序,切片取出
|
||||
result1 = my_str[::-1][9:14]
|
||||
print(f"{result1}")
|
||||
# 切片取出,然后倒叙
|
||||
result2 = my_str[5:10][::-1]
|
||||
print(f"{result2}")
|
||||
# split分割”,” replace替换“来”为空,倒叙字符串
|
||||
result3 = my_str.split(",")[1].replace("来", "")[::-1]# 写入为中文, 替换也需要为中文,
|
||||
print(f"{result3}")
|
||||
# new_my_list = ""
|
||||
# index = 0
|
||||
# while index < len(my_list):
|
||||
# element = my_list[index]
|
||||
# index += 1
|
||||
# new_my_list.extend(element)
|
||||
# new_my_list.extend(f"{my_list[::-1]}")
|
||||
# print(f"{new_my_list}")
|
||||
Reference in New Issue
Block a user