# Connect to server ```python= import requests import json r = requests.get("http://140.113.121.36:9090/homepage?UID={}&SID={}".format(cur_uid, shopid) data = json.loads(r.text) print(data) shop_list = ['a', 'b', 'c'] ``` - `http://` - 使用 http 協定 - `140.113.121.36:9090` - server 的 ip 跟 port,你要拜訪的地方 - 也是 run code - `/homepage` ``` [ {'ServerName': 'jimmy', 'ServerIP': '127.0.0.1'}, {'ServerName': 'roy', 'ServerIP': '127.0.0.2'} ] ``` ```python= Jimmy = data[0] Roy = data[1] print(Jimmy['ServerName']) print(Roy['ServerIP']) ``` ``` jimmy 127.0.0.2 ``` ## Example of 東逸的帕特/ 1.發問貼文 ```python= import requests import json r = requests.get("http://140.113.121.36:9090/askpage/ask?UID={}&content={}&color={}&time={}".format(number,self.InputText,self.ColorArray[self.ColorPointer],str(datetime.now()))) data = json.loads(r.text) print(data) ``` - 影片教學 [click](https://youtu.be/UIxyBKVPuzI) - import requests 函式庫 - 要先下載(可以直接 pip3 install requests - 這個範例有用到時間函式庫 - from datetime import datetime - 傳給後端時可以用str(datetime.now()) - 事前工作 - 取link名稱 - 統一規定第二個單字的第一個字母要大寫 ex: appleOrange - 取變數名稱 - 統一規定第二個單字的第一個字母要大寫 ex: appleOrange
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up