1.客户端使用GET方法发送数据
在project1中新建一个client.py文件,编写客户端程序:
import urllib.parse
import urllib.request
try:
s=input("输入要查询的外汇:")
value="currency="+urllib.parse.quote(s)
html=urllib.request.urlopen("http://127.0.0.1:5000?"+value)
html = html.read()
html = html.decode()
print(html)
except Exception as err:
print(err)
先运行server.py,再运行client.py,结果如下: