帝国7.0会员使用邮箱或用户名同时登陆修改教程

这个功能想必大家都想知道吧,其实修改实现起来还是非常容易的,看看方法就知道了,可以同时实现用户名或者使用注册是的邮箱进行登陆帐号。

一. 课上代码

修改方法如下:

>>> member = ['Jack', 'David', 'Hsin', 'Chi']
>>> member
['Jack', 'David', 'Hsin', 'Chi']
>>> number = [1, 2, 3, 4, 5]
>>> number
[1, 2, 3, 4, 5]
>>> mix = [1, 'Jack', 3.14, [1, 2, 3]]
>>> mix
[1, 'Jack', 3.14, [1, 2, 3]]
>>> empty = []
>>> empty
[]
>>> member
['Jack', 'David', 'Hsin', 'Chi']
>>> member.append('Shelly')
>>> member
['Jack', 'David', 'Hsin', 'Chi', 'Shelly']
#append作为一种添加元素的方法

>>> len(member)
5
>>> member.append('fishc', 'fish')
Traceback (most recent call last):
  File "<pyshell#13>", line 1, in <module>
    member.append('fishc', 'fish')
TypeError: append() takes exactly one argument (2 given)
>>> member.extend('fishc', 'fish')
Traceback (most recent call last):
  File "<pyshell#14>", line 1, in <module>
    member.extend('fishc', 'fish')
TypeError: extend() takes exactly one argument (2 given)
#append不能一次添加两个元素
#extend可以一次添加几个元素,但是需要以数组的方式添加

>>> member.extend(['fishc', 'fish'])
>>> member
['Jack', 'David', 'Hsin', 'Chi', 'Shelly', 'fishc', 'fish']
>>> len(member)
7
>>> member.insert(1, 'Rose')
>>> member
['Jack', 'Rose', 'David', 'Hsin', 'Chi', 'Shelly', 'fishc', 'fish']
>>> member.insert(0, 'Titanic')
#insert是第三种添加元素的方法,并且可以添加到特定位置

>>> member
['Titanic', 'Jack', 'Rose', 'David', 'Hsin', 'Chi', 'Shelly', 'fishc', 'fish']
>>> 

打开 e/member/class/member_loginfun.php 文件查找:

二. 测试题

$username=RepPostVar($username);
  1. member.append([‘David’, ‘Mike’])和member.extend([澳门新葡亰手机版,’David’,
    ‘Mike’])实现的效果一样吗?

修改为:

if(chemail($username)){ $username=RepPostVar($username); $r=$empire-fetch1("select username from {$dbtbpre}enewsmember where email='$username'"); $username=$r['username'];}else{ $username=RepPostVar($username);}
>>> member = ['Jack', 'Rose']
>>> member.append(['David', 'Mike'])
>>> member
['Jack', 'Rose', ['David', 'Mike']]
>>> member = ['Jack', 'Rose']
>>> member.extend(['David', 'Mike'])
>>> member
['Jack', 'Rose', 'David', 'Mike']
  1. 有列表name = [‘F’, ‘i’, ‘h’,
    ‘C’],如果想要在元素’i’和’h’之间插入元素’s’,应该使用什么方法插入?

>>> name = ['F', 'i', 'h', 'C']
>>> name.insert(1, 's')
>>> name
['F', 's', 'i', 'h', 'C']
#注意数字代表的位置
>>> name = ['F', 'i', 'h', 'C']
>>> name.insert(2, 's')
>>> name
['F', 'i', 's', 'h', 'C']

三. 动动手

  1. 假定给定一下列表:
    member = [‘fish’, ‘dark’, ‘road’, ‘quiet’, ‘sun’]
    要求将列表修改为:
    member = [‘fish’, 88, ‘dark’, 90, ‘road’, 85, ‘quiet’, 90, ‘sun’,
    88]
    方法一:使用insert()和append()方法修改列表
    方法二:重新创建一个同名字的列表覆盖