我最近开始接触 Python,想知道您是否可以发布一些关于如何编码 JSON 字符串、将其作为 HTTP 请求发送到 URL 并解析响应的代码。
这是我一直在玩的一些代码:
import os
import json
if os.name == 'nt':
def clear_console():
subprocess.call("cls", shell=True)
return
else:
def clear_console():
subprocess.call("clear", shell=True)
return
def login_call(username, password):
choice = 0
while int(choice) not in range(1,2):
clear_console()
print ('')
print (' Json Calls - Menu')
choice = input('''
1. Login.
Enter Option: ''')
print ('')
choice = int(choice)
if choice == 1:
login_call(username, password)