2019秋招运维笔试编程题

看到网上有小米的运维笔试题,我用python试着做了一下,结果应该是满足了题目要求,因为没有官方测试。

编程题一:

 

#!/usr/bin/env python
#coding:utf-8
"""
file:.py
date:2018/9/20 19:56
author:    peak
description:
"""

def test():
    times = raw_input("times:")
    N = raw_input("N:")
    K = raw_input("K:")
    ks = []
    alltimes=0

    times = times.replace('[', '')
    times = times.replace(']', '')
    times = times.replace(',', '')

    list=[]

    i = 0
    while i

 

编程题2:

 

#!/usr/bin/env python
#coding:utf-8
"""
file:.py
date:2018/9/20 22:17
author:    peak
description:
"""
def turnlist(x):
    if ',' in x:
        x = x.split(',')
        return x
    else:
        x = x.split()
        return x

def exam2():
    L1 = raw_input("N,T:")
    Str = raw_input("string:")
    L1 = turnlist(L1)
    N = L1[0]
    T = int(L1[1])

    for i in range(T):
        L2 = raw_input("type,X:")
        L2 = turnlist(L2)
        X = L2[1]
        X = int(X)
        if L2[0] == "1":
            head = Str[0:-X]
            s1 = Str.replace(head, "")
            S = s1+head
            print S
        else:
            print Str[X]
exam2()

 

你可能感兴趣的:(python,练习)