llgd.net
当前位置:首页 >> 请大神做一个python程序,输入一组数字,从中取出... >>

请大神做一个python程序,输入一组数字,从中取出...

冒泡排序 numbers = [34,12,8,21,55] #定义一个元素乱序的整数数组 for i in range(len(numbers)): #逐个遍历序列中的元素 for j in range(i): #再次间接遍历numbers中的元素.不过是比原序列都少一位 if numbers[j] > numbers[j+1]: #如果当前索...

import redef fun(s): return re.sub(r'([\d]+)','',s).lower()print fun('Abc123De4f')

from string import lowercases = 'babcbcasdfweljlkjlefghisfsdfsd'cont = []sub = []for i in s: if len(sub) >= 1 and lowercase.index(sub[-1]) + 1 != lowercase.index(i): cont.append(''.join(sub)) sub = [] sub.append(i)cont = sorted...

print sum(map(ord,list(str1.lower())))-96*len(str1) 其中str1是输入字符串 以aBC为例 str1.lower() 将所有字母变成小写字母 abc list(str1.lower()) 将字符串变成 ['a', 'b', 'c'] ord 将字母变成ASCII 数字 map(ord,list(str1.lower()))将列...

#include #include int main(){ char szNum[100] = {0}; printf("请输入一个数:\n"); scanf("%s", szNum); int a[10] = {0}; for (int i = 0; i < strlen(szNum); i++) { if ('0'

#用所给字符串测试了一下,可行def string_judg(string): for char in string: if char>='A' and char

1 astr = "Iamatestcast" 2 print astr 3 lens = len(astr) 4 cnt = {} 5 for i in range (0, lens): 6 cnt.setdefault(ord(astr[i]), 0) 7 cnt[ord(astr[i])] += 1 8 9 maxCnt = 0 10 maxLetter = ord(astr[0]) 11 for k in cnt.keys(): 12 if...

with open('1.txt', 'a+') as f: print('Input is starting, press q to quit.') loop = True while loop: input_string = input('please input something') if input_string != 'q': f.write(input_string + '\n') else: loop = False

分别输入key和value,key输入回车结束 dic = {}while True: key = input('Input key:') if key == '': break value = input('Input value:') dic[key] = valuefor key, value in dic.items(): print(key + ' : ' + value)

#coding:utf-8import redef test(str_1): str1 = str_1 len_str1 = len(str1) print len_str1 len_capital = len(re.compile(r'[A-Z]').findall(str1)) print u'大写字母有%d个'%len_capital len_lowercase = len(re.compile(r'[a-z]').findall(...

网站首页 | 网站地图
All rights reserved Powered by www.llgd.net
copyright ©right 2010-2021。
内容来自网络,如有侵犯请联系客服。zhit325@qq.com