题解 | 字符串分隔
字符串分隔
https://www.nowcoder.com/practice/d9162298cb5a437aad722fccccaae8a7
str = input()
l = len(str)
t = 8 - (l % 8)
while t > 0:
str +='0'
t -= 1
for j in range(0, l, 8):
print(str[j:j+8])
字符串分隔
https://www.nowcoder.com/practice/d9162298cb5a437aad722fccccaae8a7
str = input()
l = len(str)
t = 8 - (l % 8)
while t > 0:
str +='0'
t -= 1
for j in range(0, l, 8):
print(str[j:j+8])
相关推荐
球球与墩墩:这不是前端常考的对象扁平化吗,面试官像是前端出来的
const flattern = (obj) => {
const res = {};
const dfs = (curr, path) => {
if(typeof curr === 'object' && curr !== null) {
const isArray = Array.isArray(curr);
for(let key in curr) {
const newPath = path ? isArray ? `${path}[${key}]` : `${path}.${key}` : key;
dfs(curr[key], newPath);
}
} else {
res[path] = curr
}
}
dfs(obj);
return res;
}
查看3道真题和解析