Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
bellcode
/
lesson2-2_DIY1
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
b1d823a1
authored
Mar 27, 2021
by
BellCodeEditor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
auto save
parent
505ba83d
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
98 additions
and
13 deletions
demo.py
demos.py
diy1.py
demo.py
View file @
b1d823a1
...
@@ -23,4 +23,39 @@ com = ["石头","剪刀","布"]
...
@@ -23,4 +23,39 @@ com = ["石头","剪刀","布"]
coms
=
random
.
choice
(
com
)
coms
=
random
.
choice
(
com
)
print
(
"计算机出拳:"
+
coms
)
print
(
"计算机出拳:"
+
coms
)
if
if
play
in
com
:
\ No newline at end of file
if
coms
==
play
:
print
(
"平局"
)
elif
play
==
"石头"
and
coms
==
"剪刀"
:
print
(
"恭喜你,赢了"
)
elif
play
==
"剪刀"
and
coms
==
"布"
:
print
(
"恭喜你,赢了"
)
elif
play
==
"布"
and
coms
==
"石头"
:
print
(
"恭喜你,赢了"
)
else
:
print
(
"很遗憾,你输了"
)
else
:
print
(
"输入错误~"
)
"""
# -------------------------------------------
# 玩家出拳
# 注意:input返回的是字符串,如果需要进行计算,需要转换成整型
play = input("请玩家出拳(石头/剪刀/布):")
# -------------------------------------------
# 必须先导入模块,再使用
# 查看源码 Ctrl+左键
import random
com = ["石头","剪刀","布"]
coms = random.choice(com)
# -------------------------------------------
# 注意缩进
if (条件1):
# 条件1成立,进入这里,运行这里的代码
elif (条件2):
# 条件2成立,进入这里,运行这里的代码
elif (条件3):
# 条件3成立,进入这里,运行这里的代码
else:
# 条件1,2,3不成立,进入这里,运行这里的代码
"""
\ No newline at end of file
demos.py
0 → 100644
View file @
b1d823a1
import
requests
import
re
import
json
def
download_page
(
url
,
pc
=
True
):
if
pc
==
True
:
ua
=
'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 Safari/537.36'
else
:
ua
=
'Mozilla/5.0 (iPhone; CPU iPhone OS 11_0 like Mac OS X) AppleWebKit/604.1.38 (KHTML, like Gecko) Version/11.0 Mobile/15A372 Safari/604.1'
headers
=
{
'User-Agent'
:
ua
}
res
=
requests
.
get
(
url
,
headers
=
headers
)
return
res
if
__name__
==
'__main__'
:
# https://v.douyin.com/JyPHShN/
url
=
input
(
'输入抖音视频地址:'
)
# 获取真实地址
res1
=
download_page
(
url
)
patten
=
re
.
compile
(
'/video/(.*?)/'
)
# https://www.iesdouyin.com/share/video/6881151874846723339/?region=CN&mid=6881152095287479053&u_code=imbie9bd&titleType=title×tamp=1602169029&app=aweme&utm_campaign=client_share&utm_medium=ios&tt_from=copy&utm_source=copy
# /vodeo/ 后面那串数字就是item_ids号 6881151874846723339 通过正则获取
item_ids
=
(
patten
.
findall
(
res1
.
url
))[
0
]
# 获取视频相关数据
res2
=
download_page
(
f
'https://www.iesdouyin.com/web/api/v2/aweme/iteminfo/?item_ids={item_ids}'
)
res2_text
=
json
.
loads
(
res2
.
text
)
info
=
res2_text
[
'item_list'
][
0
]
old_addr
=
info
[
'video'
][
'play_addr'
][
'url_list'
][
0
]
new_addr
=
old_addr
.
replace
(
'playwm'
,
'play'
)
# 通过手机UA获取无水印视频地址
res3
=
download_page
(
new_addr
,
False
)
new_addr
=
res3
.
url
douyin_info
=
{
'aweme_id'
:
info
[
'aweme_id'
],
'title'
:
info
[
'desc'
],
'cover'
:
info
[
'video'
][
'cover'
][
'url_list'
][
0
],
'play_addr'
:
new_addr
}
print
(
douyin_info
)
\ No newline at end of file
diy1.py
View file @
b1d823a1
# 输入一个十以内数字,测试你的未来
#
#
输入一个十以内数字,测试你的未来
num
=
int
(
input
(
"请输入10以内的整数:"
))
#
num = int(input("请输入10以内的整数:"))
if
num
==
10
:
# if num == 10:
print
(
"未来可期~"
)
# print("未来可期~")
elif
num
>=
7
and
num
<
10
:
# elif num >= 7 and num < 10:
print
(
"未来不可限量"
)
# print("未来不可限量")
elif
num
>
3
and
num
<=
6
:
# elif num > 3 and num <= 6:
print
(
"前途不可限量"
)
# print("前途不可限量")
else
:
# else:
print
(
"努力吧~"
)
# print("努力吧~")
\ No newline at end of file
import
turtle
secd
=
0
turtle
.
write
(
secd
,
font
=
(
"Arial"
,
18
,
"normal"
))
turtle
.
done
()
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment