Created
August 17, 2022 02:45
-
-
Save Everfighting/7cc3a1f9fbaa8b9be645e7f4370765dd to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
import pandas | |
import copy | |
# 根据公司名或者app_code查询id | |
url = "http://121.5.100.192:7006/api/user_app/get_page" | |
res = requests.post(url=url, json={ | |
"page_size": 1000, | |
"page_num": 1, | |
"like_name": "" | |
}).json()["data"] | |
df = pandas.DataFrame(res) | |
df_2 = pandas.DataFrame(df.res_list.apply(lambda x: {**x}).tolist()) | |
df_2.company_name = df_2.company_name.apply(lambda x: str(x)) | |
result = copy.deepcopy(df_2)[["app_code", "company_name", "id"]] | |
company = input("请输入公司名") | |
if company: | |
result = result.loc[result.company_name.str.contains(company)] | |
print(result) | |
if result.empty: | |
result = copy.deepcopy(df_2)[["app_code", "company_name", "id"]] | |
app_code = input("请输入app_code") | |
if app_code: | |
result = result.loc[result.app_code.str.contains(app_code)] | |
print(result) | |
if result.id.count() == 1: | |
pk = result.iloc[0].id | |
print(df_2.loc[df_2.id == pk].iloc[0]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment