ARTICLE DETAIL

资讯详情

深耕网站建设、视觉设计与SEO优化的一线实战洞察。

pythontip 字符串首位连接

pythontip 字符串首位连接

字符串的连接‘+’
str1+str2
收到多个字符串使用input_str存储
调用时列表起始0
input()得到的字符串列表存储
input_str[0]+input_str[-1]

def join_first_last(input_str):
return input_str[0]+input_str[-1]

输入字符串

given_string = input()

调用函数

print(join_first_last(given_string))

返回列表