上传文件至 module/hitokoto
This commit is contained in:
parent
ec3962306e
commit
e035c8e93c
|
@ -1,5 +1,52 @@
|
|||
import requests
|
||||
import random
|
||||
|
||||
|
||||
def hitokoto(ctypet):
|
||||
try:
|
||||
|
||||
if ctypet == '动画' or ctypet == 'a':
|
||||
ctype = 'a'
|
||||
elif ctypet == '漫画' or ctypet == 'b':
|
||||
ctype = 'b'
|
||||
elif ctypet == '游戏' or ctypet == 'c':
|
||||
ctype = 'c'
|
||||
elif ctypet == '文学' or ctypet == 'd':
|
||||
ctype = 'd'
|
||||
elif ctypet == '原创' or ctypet == 'e':
|
||||
ctype = 'e'
|
||||
elif ctypet == '网络' or ctypet == 'f':
|
||||
ctype = 'f'
|
||||
elif ctypet == '其他' or ctypet == 'g':
|
||||
ctype = 'g'
|
||||
elif ctypet == '影视' or ctypet == 'h':
|
||||
ctype = 'h'
|
||||
elif ctypet == '诗词' or ctypet == 'i':
|
||||
ctype = 'i'
|
||||
elif ctypet == '网易云' or ctypet == 'j':
|
||||
ctype = 'j'
|
||||
elif ctypet == '哲学' or ctypet == 'k':
|
||||
ctype = 'k'
|
||||
elif ctypet == '抖机灵' or ctypet == 'l':
|
||||
ctype = 'l'
|
||||
|
||||
elif ctypet == '没有':
|
||||
ctype = random.choice('abcdefghijkl')
|
||||
params_value = {'c': ctype}
|
||||
hitokoto = requests.get('https://v1.hitokoto.cn', params=params_value)
|
||||
|
||||
return 0, hitokoto.json()
|
||||
else:
|
||||
return 3, None
|
||||
|
||||
params_value = {'c': ctype}
|
||||
hitokoto = requests.get('https://v1.hitokoto.cn', params=params_value)
|
||||
|
||||
return 0, hitokoto.json()
|
||||
|
||||
except IOError:
|
||||
return 2, None
|
||||
|
||||
|
||||
|
||||
|
||||
def hitokoto():
|
||||
hitokoto = requests.get('https://v1.hitokoto.cn')
|
||||
print(hitokoto.json)
|
Binary file not shown.
Loading…
Reference in New Issue
Block a user