首页
学习
活动
专区
工具
TVP
发布
精选内容/技术社群/优惠产品,尽在小程序
立即前往

Python基础知识(五)

###############简易的登录程序#############

# def login(username,pwd):

# '''

#登录

# :param username:

# :param pwd:

# :return:

# '''

# with open('db', 'r', encoding='utf-8') as f:

# for line in f:

# line = line.strip()

# line_list = line.split('$')

# if line_list[0] == username and line_list[1] == pwd:

# #print('login success!')

# return True

# return False

#

# def register(username,pwd):

# '''

# register

# :param usrname:

# :param pwd:

# :return:

# '''

# with open('db', 'a', encoding='utf-8') as f:

# temp = '\n' + username + '$' + pwd

# f.write(temp)

# return True

#

# def exist(username):

# with open('db', 'r', encoding='utf-8') as f:

# for line in f:

# line = line.strip()

# line_list = line.split('$')

# if line_list[0] == username:

# return True

# return False

#

# inp = input('1,login 2,register : ')

# if inp =='1':

# inp_user = input('username : ')

# inp_pwd = input('pwd : ')

# if login(inp_user, inp_pwd):

# print('login success!')

# else:

# print('login fail')

# elif inp =='2':

# inp_user = input('username : ')

# inp_pwd = input('pwd : ')

# if exist(inp_user):

# print('user exist! register fail!')

# elif register(inp_user,inp_pwd):

# print('register success!')

# else:

# print('input error')

#冒泡排序

#list1 = [11,22,3,4,35,68,34,88,79]

# def mysort(list):

# for i in range(len(list)):

# for j in range(len(list)-i-1):

# if list[j] > list[j+1]:

# list[j],list[j+1] = list[j+1],list[j]

# return list

#

# inp = input('input your list :')

# inp_list = inp.split(',')

# for i in range(len(inp_list)):

# inp_list[i] = int(inp_list[i])

# list_new = mysort(inp_list)

# print(list_new)

#递归:斐波拉契数列

print('==================================')

defFibonacci(depth,a1,a2):

#print(depth)

'''

:paramdepth:深度,从第几层开始找

:parama1:起始值1

:parama2:起始值2

:return:深度到10返回a1,通过i传回第一层调用者

'''

ifdepth ==10:

returna1

print(a1)

a3 = a1 + a2

i = Fibonacci(depth+1,a2,a3)

returni

Fi = Fibonacci(1,,1)

print(Fi)

  • 发表于:
  • 原文链接https://kuaibao.qq.com/s/20180612G233Q800?refer=cp_1026
  • 腾讯「腾讯云开发者社区」是腾讯内容开放平台帐号(企鹅号)传播渠道之一,根据《腾讯内容开放平台服务协议》转载发布内容。
  • 如有侵权,请联系 cloudcommunity@tencent.com 删除。

扫码

添加站长 进交流群

领取专属 10元无门槛券

私享最新 技术干货

扫码加入开发者社群
领券