python web服务

该服务是在python 2.7.15版本下的

1.最简单的web服务器

文件:server.py

#coding:utf-8
 
from wsgiref.simple_server import make_server
 
def RunServer(environ, start_response):
  start_response('200 OK', [('Content-Type', 'text/html')])
  return '

Hello, web!

' if __name__ == '__main__': httpd = make_server('localhost', 8000, RunServer) print ("Serving HTTP on port 8000...") httpd.serve_forever()

运行python .\server.py即可
在浏览器访问http://localhost:8000/

python web服务_第1张图片

2.其他python基础知识点

#encoding:utf-8
# https://blog.csdn.net/qq_30653631/article/details/90474959

print("hello python")
arr=[1,2,4]
print(arr)

flag = 3;
if flag==1:
  print("true")
elif flag == 2:
  print("flag==2")
else:
  print("false")

tuple = ( 'runoob', 786 , 2.23, 'john', 70.2 )
print("元组不允许修改")
print(tuple)
list = [ 'runoob', 786 , 2.23, 'john', 70.2 ]
print("列表-list-array")
list[2]= 2
print(list)
obj = {
  'name': 'tom',
  'age': 10
}
print(obj)
print(obj['name'])
print(obj.keys())
print(obj.values())

import re
# str = re.match('runoob', 'www.runoob.com')
str = re.search('runoob', 'www.runoob.com')
if( str != None):
  print(str.span())
  print(str.span()[0])
else:
 print(str)

你可能感兴趣的:(python,前端,开发语言)