摘要:
def list_sum(num_List): if len(num_List) == 1: return num_List[0] else: return num_List[0] + list_sum(num_List[1:]) print(list_sum([2, 4, 5, 6, 7])) 阅读全文
posted @ 2018-11-16 20:27
anobscureretreat
阅读(2055)
评论(0)
推荐(0)
摘要:
mycode = 'print("hello world")' code = """ def mutiply(x,y): return x*y print('Multiply of 2 and 3 is: ',mutiply(2,3)) """ exec(mycode) exec(code) 阅读全文
posted @ 2018-11-16 20:24
anobscureretreat
阅读(1755)
评论(0)
推荐(0)
摘要:
def is_even_num(l): enum = [] for n in l: if n % 2 == 0: enum.append(n) return enum print(is_even_num([1, 2, 3, 4, 5, 6, 7, 8, 9])) 阅读全文
posted @ 2018-11-16 20:22
anobscureretreat
阅读(1590)
评论(0)
推荐(0)
摘要:
def string_reverse(str1): rstr1 = '' index = len(str1) while index > 0: rstr1 += str1[ index - 1 ] index = index - 1 return rstr1 print(string_reverse('1... 阅读全文
posted @ 2018-11-16 20:20
anobscureretreat
阅读(153)
评论(0)
推荐(0)
摘要:
import collections my_list = [10,10,10,10,20,20,20,20,40,40,50,50,30] print("Original List : ",my_list) ctr = collections.Counter(my_list) print("Frequency of the elements in the List : ",d... 阅读全文
posted @ 2018-11-16 20:14
anobscureretreat
阅读(3317)
评论(0)
推荐(0)
摘要:
def sum_list(items): sum_numbers = 0 for x in items: sum_numbers += x return sum_numbers print(sum_list([1,2,-8])) 阅读全文
posted @ 2018-11-16 20:10
anobscureretreat
阅读(6061)
评论(0)
推荐(1)
摘要:
color = ['Red', 'Green', 'White', 'Black', 'Pink', 'Yellow'] color = [x for (i,x) in enumerate(color) if i not in (0,4,5)] print(color) 阅读全文
posted @ 2018-11-16 20:07
anobscureretreat
阅读(2401)
评论(0)
推荐(0)
摘要:
def multiply_list(items): tot = 1 for x in items: tot *= x return tot print(multiply_list([1,2,-8])) 阅读全文
posted @ 2018-11-16 20:05
anobscureretreat
阅读(1011)
评论(0)
推荐(0)
摘要:
1.变量赋值: name=lbg 等号前后不能有空格 name="Lebron James" 变量值中有空格要用双引号 echo ${name} 用${}更保险 shopt -s -o nounset 设置“先声明再使用” 2.取消变量: unset ... 阅读全文
posted @ 2018-11-16 14:07
anobscureretreat
阅读(423)
评论(0)
推荐(0)
摘要:
一句话判断 1.判断变量 read -p "input a word :" word if [ ! -n "$word" ] ;then echo "you have not input a word!" else echo "the word you input is $word" fi 或者 # 阅读全文
posted @ 2018-11-16 13:46
anobscureretreat
阅读(1844)
评论(0)
推荐(0)
摘要:
地址栏: 输出: 阅读全文
posted @ 2018-11-16 12:37
anobscureretreat
阅读(1308)
评论(0)
推荐(0)
摘要:
def long_words(n, str): word_len = [] txt = str.split(" ") for x in txt: if len(x) > n: word_len.append(x) return word_len print(long_words(3, "Th... 阅读全文
posted @ 2018-11-16 10:33
anobscureretreat
阅读(1675)
评论(0)
推荐(0)
摘要:
def match_words(words): ctr = 0 for word in words: if len(word) > 1 and word[0] == word[-1]: ctr += 1 return ctr print(match_words(['abc', 'xyz', 'aba', '122771'])... 阅读全文
posted @ 2018-11-16 10:29
anobscureretreat
阅读(1283)
评论(0)
推荐(0)
摘要:
def count_range_in_list(li, min, max): ctr = 0 for x in li: if min <= x <= max: ctr += 1 return ctr list1 = [10,20,30,40,40,40,70,80,99] print(count... 阅读全文
posted @ 2018-11-16 10:24
anobscureretreat
阅读(1466)
评论(0)
推荐(0)
摘要:
def common_data(list1, list2): result = False for x in list1: for y in list2: if x == y: result = True return result print(common... 阅读全文
posted @ 2018-11-16 10:17
anobscureretreat
阅读(1120)
评论(0)
推荐(0)
摘要:
nums = [5, 15, 35, 8, 98] for num_index, num_val in enumerate(nums): print(num_index, num_val) 阅读全文
posted @ 2018-11-16 10:12
anobscureretreat
阅读(3162)
评论(0)
推荐(0)
摘要:
def is_Sublist(l, s): sub_set = False if s == []: sub_set = True elif s == l: sub_set = True elif len(s) > len(l): sub_set = False els... 阅读全文
posted @ 2018-11-16 10:09
anobscureretreat
阅读(1944)
评论(0)
推荐(0)
摘要:
输出 阅读全文
posted @ 2018-11-16 01:58
anobscureretreat
阅读(13077)
评论(0)
推荐(2)
摘要:
CharField #字符串字段, 用于较短的字符串. #CharField 要求必须有一个参数 maxlength, 用于从数据库层和Django校验层限制该字段所允许的最大字符数. IntegerField #用于保存一个整数. FloatField # 一个浮点数. 必须 提供两个参数: # ... 阅读全文
posted @ 2018-11-16 01:57
anobscureretreat
阅读(406)
评论(0)
推荐(0)

浙公网安备 33010602011771号