return list[0] if list[0] > list[1] else list[1]
等同于
if list[0] > list[1] :
(缩进)return list[0]
return list[1]
看我总结里面的三元表达式
def calc(numbers):
sum = 0
for n in numbers:
sum = sum + n n
print (n,numbers)
return sum
结果:
1 [1, 2, 3]
2 [1, 2, 3]
3 [1, 2, 3]
for n(循环次数),numbers(需要的处理的数组)
list2 = [1, 2, 3, 4, 5, 6, 7 ];
print (calc(list2))
list直接放numbers就可以了
简单的,可以使用python 的CGI模块,需要你的服务器开启CGI支持。
网页内容如下:
1
2
3
4
5
6
7
8
9
10
11
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>python cgi</title>
</head><body>
<p style="font-size:24pt;color:red">输入登录密码:</p>
<form name="zhaji" action="loginpy" method="post">
<p>密 码:<input type="password" name="ma" size="9"></p>
<input type="button" name="shuru" value="登录" onclick="zhajisubmit()">
</form>
</body></html>
loginpy文件内容如下:
1
2
3
4
5
6
7
8
9
#!/usr/bin/python
#coding:utf-8
import cgi
form = cgiFieldStorage()
ma = ""
if 'ma' in form:
ma = form["ma"]value
print '''Content-Type: text/html\n\n'''
print '''<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>python cgi</title></head><body><p>你输入的密码是:%s</p> </body></html>''' % ma
欢迎分享,转载请注明来源:表白网
评论列表(0条)