题解 | #截取字符串#

截取字符串

http://www.nowcoder.com/practice/a30bbc1a0aca4c27b86dd88868de4a4a

# -*- coding: utf-8 -*-
while True:
    try:
        str_n = raw_input()#获得字符串
        k = int(input())#获得k
        srt_out = []
        for x in range(k):
            srt_out.append(str_n[x])
        print(str(srt_out).replace("[","").replace("]","").replace(",","").replace("'", "").replace(" ", ""))#将列表转化为字符串
    except:
        break

全部评论

相关推荐

03-27 01:58
已编辑
西北工业大学 Java
在平静中度过当下:如果这个bg也简历挂的话可能他们现在不缺人了吧,我也是这两天投的,阿里和快手投的岗都是简历秒挂
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务