题解 | #截取字符串#
截取字符串
http://www.nowcoder.com/practice/a30bbc1a0aca4c27b86dd88868de4a4a
HJ46 截取字符串
思路:
step1:首先输入一个字符串和一个整数k;
step2:按照切片原则,切取坐标为"0 ~ k-1"的字符([:k]),并输出打印
代码如下:
n = input()
k = int(input())
print(n[:k])
截取字符串
http://www.nowcoder.com/practice/a30bbc1a0aca4c27b86dd88868de4a4a
n = input()
k = int(input())
print(n[:k])
相关推荐