提交 478facf3 编写于 作者: ToTensor's avatar ToTensor

send topic success

上级 83b5506a
.vscode
.idea
.DS_Store
__pycache__
*.pyc
*.zip
*.out
helper.py
test.md
20211203Python编程无师自通.csv
data_backup
test_dir
test.html
\ No newline at end of file
{
"Python编程无师自通": "c798a5992a654857867ec15660e1c32a",
"全程软件测试(第3版)": "825acb73c85c4c4bb9632afe858bc097",
"深入剖析Nginx": "608fd0c7025a4a34a97a29897b067d24",
"前端体验设计——HTML5+CSS3终极修炼": "c4eeb42b07f54b42a9fd1568b8ec4b98",
"零基础学机器学习": "b88b00f6ad14402ea66695d6809614da"
}
\ No newline at end of file
# http://tinyurl.com/z6facmk
global _start
section .text
_start:
mov rax , 1
mov rdi , 1
mov rsi , message
mov rdx , 13
syscall
; exit(0)
mov eax , 60
xor rdi , rdi
syscall
message:
db "Hello, World!", 10
\ No newline at end of file
# http://tinyurl.com/zhj8ap6
print("Hello, World!")
\ No newline at end of file
# http://tinyurl.com/hp2plhs
# 该代码有一个错误
my_string = "Hello World.
\ No newline at end of file
# http://tinyurl.com/jxpztcx
# 该代码有一个错误
10 / 0
\ No newline at end of file
# http://tinyurl.com/gtp6amr
# 该代码有一个错误
y = 2
x =1
\ No newline at end of file
# http://tinyurl.com/jerpe6u
# 偶数
12 % 2
\ No newline at end of file
# http://tinyurl.com/hh9fqzy
14 // 3
> 4
\ No newline at end of file
# http://tinyurl.com/zlkjjdp
14 / 3
> 4.666666666666667
\ No newline at end of file
# http://tinyurl.com/hgjyj7o
2 + 2 * 2
\ No newline at end of file
# http://tinyurl.com/jm7cxzp
100 > 10
\ No newline at end of file
# http://tinyurl.com/gsdhr8q
100 < 10
\ No newline at end of file
# http://tinyurl.com/zdqghb2
1 == 1 and 2 == 2
\ No newline at end of file
# http://tinyurl.com/zpvk56u
1 == 1 and 10 != 2 and 2 < 10
\ No newline at end of file
# http://tinyurl.com/hosuh7c
1 == 1 or 1 == 2
\ No newline at end of file
# http://tinyurl.com/ja9mech
1 == 1 or 1 == 2 or 1 == 3
\ No newline at end of file
# http://tinyurl.com/h45eq6v
not 1 == 1
\ No newline at end of file
# 不要执行
If (expression) Then
(code_area1)
Else
(code_area2)
\ No newline at end of file
# http://tinyurl.com/htvy6g3
home = "America"
if home == "America":
print("Hello, America!")
else:
print("Hello, World!")
\ No newline at end of file
# http://tinyurl.com/jytyg5x
home = "Canada"
if home == "America":
print("Hello, America!")
else:
print("Hello, World!")
\ No newline at end of file
# http://tinyurl.com/jyg7dd2
home = "America"
if home == "America":
print("Hello, America!")
\ No newline at end of file
# http://tinyurl.com/z24ckye
x = 2
if x == 2:
print("The number is 2.")
if x % 2 == 0:
print("The number is even.")
if x % 2 != 0:
print("The number is odd.")
\ No newline at end of file
# http://tinyurl.com/zrodgne
x = 10
y = 11
if x == 10:
if y == 11:
print(x + y)
\ No newline at end of file
# http://tinyurl.com/jpr265j
home = "Thailand"
if home == "Japan":
print("Hello, Japan!")
elif home == "Thailand":
print("Hello, Thailand!")
elif home == "India":
print("Hello, India!")
elif home == "China":
print("Hello, China!")
else:
print("Hello, World!")
\ No newline at end of file
# http://tinyurl.com/zdvuuhs
home = "Mars"
if home == "America":
print("Hello, America!")
elif home == "Canada":
print("Hello, Canada!")
elif home == "Thailand":
print("Hello, Thailand!")
elif home == "Mexico":
print("Hello, Mexico!")
else:
print("Hello, World!")
\ No newline at end of file
# http://tinyurl.com/hzyxgf4
x = 100
if x == 10:
print("10!")
elif x == 20:
print("20!")
else:
print("I don't know!")
if x == 100:
print("x is 100!")
if x % 2 == 0:
print("x is even!")
else:
print("x is odd!")
\ No newline at end of file
# http://tinyurl.com/jrowero
print("Hello, World!")
\ No newline at end of file
# http://tinyurl.com/zfz3eel
for i in range(100):
print("Hello, World!")
\ No newline at end of file
# http://tinyurl.com/hpwkdo4
x = 100
if x == 10:
print("10!")
elif x == 20:
print("20!")
else:
print("I don't know!")
if x == 100:
print("x is 100!")
if x % 2 == 0:
print("x is even!")
else:
print("x is odd!")
\ No newline at end of file
# http://tinyurl.com/zlgcwoc
print("Michael")
print("Jordan")
\ No newline at end of file
# http://tinyurl.com/h4qntgk
for i in range(100):
print("Hello, World!")
\ No newline at end of file
# http://tinyurl.com/hut6nwu
# 这是一行注释
print("Hello, World!")
\ No newline at end of file
# http://tinyurl.com/jpzlwqq
# 打印 Hello, World!
print("Hello, World!")
\ No newline at end of file
# http://tinyurl.com/z52c8z8
import math
# 对角线的长度
l = 4
w = 10
d = math.sqrt(l**2+ w**2)
\ No newline at end of file
# http://tinyurl.com/zh5g2a3
print("Python")
\ No newline at end of file
# http://tinyurl.com/jq2w5ro
# 第一行
# 第二行
# 第三行
\ No newline at end of file
# http://tinyurl.com/zcdx3yo
print("""This is a really really
really really long line of
code.""")
\ No newline at end of file
# http://tinyurl.com/hjcf2sa
print\
("""This is a really really
really long line of code.""")
\ No newline at end of file
# http://tinyurl.com/glp9xq6
for i in range(100):
print("Hello, World!")
\ No newline at end of file
# http://tinyurl.com/hwa2zae
# 这是一个 JavaScript 程序
# 不过没法执行
for (i = 0; i < 100; i++) {
console.log("Hello, World!");
}
\ No newline at end of file
# http://tinyurl.com/hh5kjwp
"Hello, World!"
\ No newline at end of file
# http://tinyurl.com/guoc4gy
2.2 + 2.2
\ No newline at end of file
# http://tinyurl.com/hw64mrr
b = 100
b
\ No newline at end of file
# http://tinyurl.com/hw97que
x = 100
x
x = 200
x
\ No newline at end of file
# http://tinyurl.com/z8hv5j5
x = 10
y = 10
z = x + y
z
a = x - y
a
\ No newline at end of file
# http://tinyurl.com/zvzf786
x = 10
x = x + 1
x
\ No newline at end of file
# http://tinyurl.com/gmuzdr9
x = 10
x = x - 1
x
\ No newline at end of file
# http://tinyurl.com/zdva5wq
x = 10
x += 1
x
\ No newline at end of file
# http://tinyurl.com/jsygqcy
hi = "Hello, World!"
# http://tinyurl.com/h47ty49
my_float = 2.2
# http://tinyurl.com/hx9xluq
my_boolean = True
\ No newline at end of file
# http://tinyurl.com/j7c2npf
print("Hello, World!")
\ No newline at end of file
# http://tinyurl.com/h79ob7s
for i in range(100):
print("Hello, World!")
\ No newline at end of file
# http://tinyurl.com/zptktex
x = 100
print(x)
\ No newline at end of file
# http://tinyurl.com/hmwr4kd
print(100)
\ No newline at end of file
# 请不要运行代码
f(x) = x * 2
\ No newline at end of file
# 请不要执行代码
def [函数名]([参数]):
[函数定义]
\ No newline at end of file
# http://tinyurl.com/j9dctwl
def f(x):
return x * 2
\ No newline at end of file
# http://tinyurl.com/zheas3d
# 接上一个示例
f(2)
\ No newline at end of file
# http://tinyurl.com/gspjcgj
# 接上一个示例
result = f(2)
print(result)
\ No newline at end of file
# http://tinyurl.com/znqp8fk
def f(x):
return x + 1
z = f(4)
if z == 5:
print("z is 5")
else:
print("z is not 5")
\ No newline at end of file
# http://tinyurl.com/htk7tr6
def f():
return 1 + 1
result = f()
print(result)
\ No newline at end of file
# http://tinyurl.com/gqmkft7
def f(x, y, z):
return x + y + z
result = f(1, 2, 3)
print(result)
\ No newline at end of file
# http://tinyurl.com/j8qyqov
def f():
z = 1 + 1
result = f()
print(result)
\ No newline at end of file
# http://tinyurl.com/zfkzqw6
len("Monty")
\ No newline at end of file
# http://tinyurl.com/juzxg2z
str(100)
\ No newline at end of file
# http://tinyurl.com/j42qhkf
int("1")
\ No newline at end of file
# http://tinyurl.com/hnk8gh2
fload(100)
\ No newline at end of file
# http://tinyurl.com/jcchmlx
int("110")
int(20.54)
float("16.4")
float(99)
\ No newline at end of file
# http://tinyurl.com/zseo21s
int("Prince")
\ No newline at end of file
# http://tinyurl.com/zynprpg
age = input("Enter your age:")
int_age = int(age)
if int_age < 21:
print("You are young!")
else:
print("Wow, you are old!")
\ No newline at end of file
# http://tinyurl.com/zhy8y4m
def even_odd(x):
if x % 2 == 0:
print("even")
else:
print("odd")
even_odd(2)
even_odd(3)
\ No newline at end of file
# http://tinyurl.com/jk8lugl
n = input("type a number:")
n = int(n)
if n % 2 == 0:
print("n is even.")
else:
print("n is odd.")
n = input("type a number:")
n = int(n)
if n % 2 == 0:
print("n is even.")
else:
print("n is odd.")
n = input("type a number:")
n = int(n)
if n % 2 == 0:
print("n is even.")
else:
print("n is odd.")
\ No newline at end of file
# http://tinyurl.com/zzn22mz
def even_odd():
n = input("type a number:")
n = int(n)
if n % 2 == 0:
print("n is even.")
else:
print("n is odd.")
even_odd()
even_odd()
even_odd()
\ No newline at end of file
# http://tinyurl.com/h3ych4h
def f(x=2):
return x ** x
print(f())
print(f(4))
\ No newline at end of file
# http://tinyurl.com/hm5svn9
def add_it(x, y=10):
return x + y
result = add_it(2)
print(result)
\ No newline at end of file
# http://tinyurl.com/zhmxnqt
x = 1
y = 2
z = 3
\ No newline at end of file
# http://tinyurl.com/hgvnj4p
x = 1
y = 2
z = 3
def f():
print(x)
print(y)
print(z)
f()
\ No newline at end of file
# http://tinyurl.com/znka93k
def f():
x = 1
y = 2
z = 3
print(x)
print(y)
print(z)
\ No newline at end of file
# http://tinyurl.com/z2k3jds
def f():
x = 1
y = 2
z = 3
print(x)
print(y)
print(z)
f()
\ No newline at end of file
# http://tinyurl.com/zn8zjmr
if x > 100:
print("x is > 100")
\ No newline at end of file
# http://tinyurl.com/zclmda7
x = 100
def f():
global x
x += 1
print(x)
f()
\ No newline at end of file
# http://tinyurl.com/jcg5qwp
a = input("type a nubmer:")
b = input("type another:")
a = int(a)
b = int(b)
print(a / b)
\ No newline at end of file
# http://tinyurl.com/ztpcjs4
a = input("type a nubmer:")
b = input("type another:")
a = int(a)
b = int(b)
print(a / b)
\ No newline at end of file
# http://tinyurl.com/j2scn4f
a = input("type a nubmer:")
b = input("type another:")
a = int(a)
b = int(b)
try:
print(a / b)
except ZeroDivisionError:
print("b cannot be zero.")
\ No newline at end of file
a = input("type a nubmer:")
b = input("type another:")
a = int(a)
b = int(b)
try:
print(a / b)
except ZeroDivisionError:
print("b cannot be zero.")
\ No newline at end of file
# http://tinyurl.com/jlus42v
try:
a = input("type a nubmer:")
b = input("type another:")
a = int(a)
b = int(b)
print(a / b)
except (ZeroDivisionError,
ValueError):
print("Invalid input.")
\ No newline at end of file
# http://tinyurl.com/hockur5
try:
10 / 0
c = "I will never get defined."
except ZeroDivisionError:
print(c)
\ No newline at end of file
# http://tinyurl.com/zhahdcg
def add(x, y):
"""
返回 x + y 的值
:param x: int.
:param y: int.
:return: int, x 与 y 之和
"""
return x + y
\ No newline at end of file
# http://tinyurl.com/zdllght
"Hello".upper()
\ No newline at end of file
# http://tinyurl.com/h4go6kg
fruit = list()
fruit
\ No newline at end of file
# http://tinyurl.com/j52uvmq
colors = ["blue", "green", "yellow"]
colors
item = colors.pop()
item
colors
\ No newline at end of file
# http://tinyurl.com/jjxnk4z
colors1 = ["blue", "green", "yellow"]
colors2 = ["orange", "pink", "black"]
colors1 + colors2
\ No newline at end of file
# http://tinyurl.com/z4fnv39
colors = ["blue", "green", "yellow"]
"green" in colors
\ No newline at end of file
# http://tinyurl.com/jqzk8pj
colors = ["blue", "green", "yellow"]
"black" not in colors
\ No newline at end of file
# http://tinyurl.com/hhx6rx4
len(colors)
\ No newline at end of file
# http://tinyurl.com/gq7yjr7
colors = ["purple",
"orange",
"green"]
guess = input("Guess a color:")
if guess in colors:
print("You guessed correctly!")
else:
print("Wrong! Try again.")
\ No newline at end of file
# http://tinyurl.com/jft8p7x
fruit = []
fruit
\ No newline at end of file
# http://tinyurl.com/h2y8nos
fruit = ["Apple", "Orange", "Pear"]
fruit
\ No newline at end of file
# http://tinyurl.com/h9w3z2m
fruit = ["Apple", "Orange", "Pear"]
fruit.append("Banana")
fruit.append("Peach")
fruit
\ No newline at end of file
# http://tinyurl.com/zhpntsr
random = []
random.append(True)
random.append(100)
random.append(1.1)
random.append("Hello")
random
\ No newline at end of file
# http://tinyurl.com/z8zzk8d
fruit = ["Apple", "Orange", "Pear"]
\ No newline at end of file
# http://tinyurl.com/jqtlwpf
fruit = ["Apple", "Orange", "Pear"]
fruit[0]
fruit[1]
fruit[2]
\ No newline at end of file
# http://tinyurl.com/za3rv95
colors = ["blue", "green", "yellow"]
colors[4]
\ No newline at end of file
# http://tinyurl.com/h4ahvf9
colors = ["blue", "green", "yellow"]
colors
colors[2] = "red"
colors
\ No newline at end of file
# http://tinyurl.com/zo88eal
my_tuple = tuple()
my_tuple
\ No newline at end of file
# http://tinyurl.com/zm3y26j
my_tuple = ()
my_tuple
\ No newline at end of file
# http://tinyurl.com/zlwwfe3
rndm = ("M. Jackson", 1958, True)
rndm
\ No newline at end of file
# http://tinyurl.com/j8mca8o
# 这是元组
("self_taught", )
# 这不是元组
(9) + 1
\ No newline at end of file
# http://tinyurl.com/z3x34nk
dys = ("1984",
"Brave New World",
"Fahrenheit 451")
dys[1] = "Handmaid's Tale"
\ No newline at end of file
# http://tinyurl.com/z9dc6lo
dys = ("1984",
"Brave New World",
"Fahrenheit 451")
dys[2]
\ No newline at end of file
# http://tinyurl.com/j3bsel7
dys = ("1984",
"Brave New World",
"Fahrenheit 451")
"1984" in dys
\ No newline at end of file
# http://tinyurl.com/jpdjjv9
dys = ("1984",
"Brave New World",
"Fahrenheit 451")
"Handmaid's Tale" not in dys
\ No newline at end of file
# http://tinyurl.com/zfn6jmw
my_dict = dict()
my_dict
\ No newline at end of file
# http://tinyurl.com/jfgemf2
my_dict = {}
my_dict
\ No newline at end of file
# http://tinyurl.com/hplqc4u
fruits = {"Apple":
"Red",
"Banana":
"Yellow"}
fruits
\ No newline at end of file
# http://tinyurl.com/grc28lh
facts = dict()
# 添加键-值对
facts["code"] = "fun"
# 查找键对应的值
facts["code"]
# 添加键-值对
facts["Bill"] = "Gates"
# 查找键对应的值
facts["Bill"]
# 添加键-值对
facts["founded"] = 1776
# 查找键对应的值
facts["founded"]
\ No newline at end of file
# http://tinyurl.com/hgf9vmp
bill = dict({"Bill Gates":
"charitable"})
"Bill Gates" in bill
\ No newline at end of file
# http://tinyurl.com/he3g993
bill = dict({"Bill Gates":
"charitable"})
"Bill Doors" not in bill
\ No newline at end of file
# http://tinyurl.com/htrd9lj
books = {"Dracula": "Stoker",
"1984": "Orwell",
"The Trial": "Kafka"}
del books["The Trial"]
books
\ No newline at end of file
# http://tinyurl.com/gnjvep7
rhymes = {"1": "fun",
"2": "blue"
"3": "me",
"4": "floor",
"5": "live"
}
n = input("Type a number:")
if n in rhymes:
rhyme = rhymes[n]
print(rhyme)
else:
print("Not found.")
Type a number:
\ No newline at end of file
# http://tinyurl.com/gops9fz
lists = []
rap = ["Kanye West",
"Jay Z",
"Eminem",
"Nas"]
rock = ["Bob Dylan",
"The Beatles",
"Led Zeppelin"]
djs = ["Zeds Dead",
"Tiesto"]
lists.append(rap)
lists.append(rock)
lists.append(djs)
print(lists)
\ No newline at end of file
# http://tinyurl.com/gu4mudk
# 接上例
rap = lists[0]
print(rap)
\ No newline at end of file
# http://tinyurl.com/hdtosm2
# 接上例
rap = lists[0]
rap.append("Kendrick Lamar")
print(rap)
print(lists)
\ No newline at end of file
# http://tinyurl.com/z9dhema
locations = []
la = (34.0522, 188.2437)
chicago = (41.8781, 87.6298)
locations.append(la)
locations.append(chicago)
print(locations)
\ No newline at end of file
# http://tinyurl.com/zqupwx4
ny = {"locations":
(40.7128,
74.0059),
"celebs":
["W. Allen",
"Jay Z",
"K. Bacon"],
"facts":
{"state":
"NY",
"country":
"America"}
}
\ No newline at end of file
# http://tinyurl.com/jfndhgx
s = " The "
s = s.strip()
s
\ No newline at end of file
# http://tinyurl.com/zha4uwo
equ = "All animals are equal."
equ = equ.replace("a", "@")
print(equ)
\ No newline at end of file
# http://tinyurl.com/hzc6asc
"animals".index("m")
\ No newline at end of file
# http://tinyurl.com/jmtc984
"animals".index("z")
\ No newline at end of file
# http://tinyurl.com/zl6q4fd
try:
"animals".index("z")
except:
print("Not found.")
\ No newline at end of file
# http://tinyurl.com/hsnygwz
"Cat" in "Cat in the hat."
\ No newline at end of file
# http://tinyurl.com/jz8sygd
"Potter" not in "Harry"
\ No newline at end of file
# http://tinyurl.com/zj6hc4r
# 该段代码无法执行。
"She said "Surely.""
\ No newline at end of file
# http://tinyurl.com/jdsrr7e
"She said \"Surely.\""
\ No newline at end of file
# http://tinyurl.com/hoef63o
"She said 'Surely'"
\ No newline at end of file
# http://tinyurl.com/zkgfawo
'She said "Surely."'
\ No newline at end of file
# http://tinyurl.com/zyrhaeg
print("line1\nline2\nline3")
\ No newline at end of file
# http://tinyurl.com/h2rqj2a
fict = ["Tolstoy",
"Camus",
"Orwell",
"Huxley",
"Austin"]
fict[0:3]
\ No newline at end of file
# http://tinyurl.com/hug9euj
ivan = """In place of death there was light."""
ivan[0:17]
ivan[17:33]
\ No newline at end of file
# http://tinyurl.com/judcpx4
ivan = """In place of death there was light."""
ivan[:17]
\ No newline at end of file
# http://tinyurl.com/zqoscn4
ivan = """In place of death there was light."""
ivan[17:]
\ No newline at end of file
# http://tinyurl.com/zqvuqoc
ivan = """In place of death there was light."""
ivan[:]
\ No newline at end of file
# http://tinyurl.com/h59ygda
""" 第一行
第二行
第三行
"""
\ No newline at end of file
# http://tinyurl.com/zqqc2jw
author = "Kafka"
author[0]
author[1]
author[2]
author[3]
author[4]
\ No newline at end of file
# http://tinyurl.com/zk52tef
author = "Kafka"
author[5]
\ No newline at end of file
# http://tinyurl.com/hyju2t5
author = "Kafka"
author[-1]
\ No newline at end of file
# http://tinyurl.com/jtpx7sr
author = "Kafka"
author[-2]
author[-3]
\ No newline at end of file
# http://tinyurl.com/hsr83lv
ff = "F.Fitzgerald"
ff = "F. Scott Fitzgerald"
ff
\ No newline at end of file
# http://tinyurl.com/h4z5mlg
"cat" + "in" + "hat"
\ No newline at end of file
# http://tinyurl.com/zvm9gng
"Sawyer" * 3
\ No newline at end of file
# http://tinyurl.com/hhancz6
"We hold these truths...".upper()
\ No newline at end of file
# http://tinyurl.com/zkz48u5
"SO IT GOES.".lower()
\ No newline at end of file
# http://tinyurl.com/jp5hexn
"four score and...".capitalize()
\ No newline at end of file
# http://tinyurl.com/juvguy8
"William {}".format("Faulkner")
\ No newline at end of file
# http://tinyurl.com/zcpt9se
last = "Faulkner"
"William {}".format(last)
\ No newline at end of file
# http://tinyurl.com/z6t6d8n
author = "William Faulkner"
year_born = "1897"
"{} was born in {}.".format(author, year_born)
\ No newline at end of file
# http://tinyurl.com/gnrdsj9
n1 = input("Enter a noun:")
v = input("Enter a verb:")
adj = input("Enter an adj:")
n2 = input("Enter a noun:")
r = """The {} {} the {} {}
""".format(n1,
v,
adj,
n2)
print(r)
\ No newline at end of file
# http://tinyurl.com/he8u28o
"I jumped over the puddle. It was 12 feet!".split(".")
\ No newline at end of file
# http://tinyurl.com/h2pjkso
first_three = "abc"
result = "+".join(first_three)
result
\ No newline at end of file
# http://tinyurl.com/z49e3up
words = ["The",
"fox",
"jumped",
"over",
"the",
"fence",
"."]
one = "".join(words)
one
\ No newline at end of file
# http://tinyurl.com/h4qq5oy
words = ["The",
"fox",
"jumped",
"over",
"the",
"fence",
"."]
one = " ".join(words)
one
\ No newline at end of file
# http://tinyurl.com/jya6kpm
name = "Ted"
for character in name:
print(character)
\ No newline at end of file
# http://tinyurl.com/zeftpq8
shows = ["GOT",
"Narcos",
"Vice"]
for show in shows:
print(show)
\ No newline at end of file
# http://tinyurl.com/gpr5a6e
coms = ("A. Development",
"Friends",
"Always Sunny")
for show in coms:
print(show)
\ No newline at end of file
# http://tinyurl.com/jk7do9b
people = {"G. Bluth II":
"A. Development",
"Barney":
"HIMYM",
"Dennis":
"Always Sunny"
}
for character in people:
print(character)
\ No newline at end of file
# http://tinyurl.com/j8wvp8c
tv = ["GOT",
"Narcos",
"Vice"]
i = 0
for show in tv:
new = tv[i]
new = new.upper()
tv[i] = new
i += 1
print(tv)
\ No newline at end of file
# http://tinyurl.com/z45g63j
tv = ["GOT", "Narcos",
"Vice"]
for i, show in enumerate(tv):
new = tv[i]
new = new.upper()
tv[i] = new
print(tv)
\ No newline at end of file
# http://tinyurl.com/zcvgklh
tv = ["GOT", "Narcos",
"Vice"]
coms = ["Arrested Development",
"friends",
"Always Sunny"]
all_shows = []
for show in tv:
show = show.upper()
all_shows.append(show)
for show in coms:
show = show.upper()
all_shows.append(show)
print(all_shows)
\ No newline at end of file
# http://tinyurl.com/hh5t8rw
for i in range(1, 11):
print(i)
\ No newline at end of file
# http://tinyurl.com/j2gwlcy
x = 10
while x > 0:
print('{}'.format(x))
x -= 1
print("Happy New Year!")
\ No newline at end of file
# http://tinyurl.com/hcwvfk8
while True:
print("Hello, World!")
\ No newline at end of file
# http://tinyurl.com/zrdh88c
for i in range(0, 100):
print(i)
\ No newline at end of file
# http://tinyurl.com/zhxf3uk
for i in range(0, 100):
print(i)
break
\ No newline at end of file
# http://tinyurl.com/jmak8tr
qs = ["What is your name?",
"What is your fav. color?",
"What is your quest?"]
n = 0
while True:
print("Type q to quit")
a = input(qs[n])
if a == "q":
break
n = (n + 1) % 3
Type q to quit
What is your name?
\ No newline at end of file
# http://tinyurl.com/hflun4p
for i in range(1, 6):
if i == 3:
continue
print(i)
\ No newline at end of file
# http://tinyurl.com/gp7forl
i = 1
while i <= 5 :
if i == 3:
i += 1
continue
print(i)
i += 1
\ No newline at end of file
# http://tinyurl.com/gqjxjtq
for i in range(1, 3):
print(i)
for letter in ["a", "b", "c"]:
print(letter)
\ No newline at end of file
# http://tinyurl.com/z7duawp
list1 = [1, 2, 3, 4]
list2 = [5, 6, 7, 8]
added = []
for i in list1:
for j in list2:
added.append(i + j)
print(added)
\ No newline at end of file
# http://tinyurl.com/hnprmmv
while input('y or n?') != 'n':
for i in range(1, 6):
print(i)
\ No newline at end of file
# http://tinyurl.com/h3ds93u
import math
\ No newline at end of file
# http://tinyurl.com/hyjo59s
import math
math.pow(2, 3)
\ No newline at end of file
# http://tinyurl.com/hr3fppn
# 你运行的时候输出结果可能不是 52
# 因为是随机生成的!
import random
random.randint(0, 100)
\ No newline at end of file
# http://tinyurl.com/jrnznoy
import statistics
# 均值
nums = [1, 5, 33, 12, 46, 33, 2]
statistics.mean(nums)
# 中值
statistics.median(nums)
# 众数
statistics.mode(nums)
\ No newline at end of file
# http://tinyurl.com/zjphfho
import keyword
keyword.iskeyword("for")
keyword.iskeyword("football")
\ No newline at end of file
# http://tinyurl.com/z5v9hk3
def print_hello():
print("Hello")
\ No newline at end of file
# http://tinyurl.com/j4xv728
import hello
hello.print_hello()
\ No newline at end of file
# http://tinyurl.com/zgyddhp
# 模块1中的代码
print("Hello!")
\ No newline at end of file
# http://tinyurl.com/jamt9dy
# 模块2中的代码
import hello
\ No newline at end of file
# http://tinyurl.com/j2xdzc7
# 模块1中的代码
if __name__ == "__main__":
print("Hello!")
\ No newline at end of file
# http://tinyurl.com/jjccxds
# 模块2中的代码
import hello
\ No newline at end of file
# http://tinyurl.com/hkqfkar
import os
os.path.join("Users",
"bob",
"st.txt")
\ No newline at end of file
# http://tinyurl.com/zfgczj5
st = open("st.txt", "w")
st.write("Hi from Python!")
st.close()
\ No newline at end of file
# http://tinyurl.com/jt9guu2
with open("st.txt", "w") as f:
f.write("Hi from Python!")
\ No newline at end of file
# http://tinyurl.com/hmuamr7
# 确保在上例中已经
# 创建了文件
with open("st.txt", "r") as f:
print(f.read())
\ No newline at end of file
# http://tinyurl.com/hkzhxdz
my_list = list()
with open("st.txt", "r") as f:
my_list.append(f.read())
print(my_list)
\ No newline at end of file
# http://tinyurl.com/go9wepf
import csv
with open("st.csv", "w") as f:
w = csv.writer(f,
delimiter=",")
w.writerow(["one",
"two",
"three"])
w.writerow(["four",
"five",
"six"])
\ No newline at end of file
# http://tinyurl.com/gvcdgxf
#确保已经在上例中创建了数据文件
import csv
with open("st.csv", "r") as f:
r = csv.reader(f, delimiter=",")
for row in r:
print(",".join(row))
\ No newline at end of file
# http://tinyurl.com/jhrvs94
def hangman(word):
wrong = 0
stages = ["",
" ",
"| ",
"| | ",
"| 0 ",
"| /|\ ",
"| / \ ",
"| "
]
rletters = list(word)
board = ["__"] * len(word)
win = False
print("Welcome to Hangman")
\ No newline at end of file
# http://tinyurl.com/ztrp5jc
while wrong < len(stages) - 1:
print("\n")
msg = "Guess a letter"
char = input(msg)
if char in rletters:
cind = rletters.index(char)
board[cind] = char
rletters[cind] = '$'
else:
wrong += 1
print((" ".join(board)))
e = wrong + 1
print("\n".join(stages[0:e]))
if "__" not in board:
print("You win!")
print(" ".join(board))
win = True
break
\ No newline at end of file
# http://tinyurl.com/zqklqxo
if not win:
print("\n".join(stages[0:wrong]))
print("You lose! It was {}.".format(word))
\ No newline at end of file
# http://tinyurl.com/h9q2cpc
def hangman(word):
wrong = 0
stages = ["",
" ",
"| ",
"| | ",
"| 0 ",
"| /|\ ",
"| / \ ",
"| "
]
rletters = list(word)
board = ["__"] * len(word)
win = False
print("Welcome to Hangman")
while wrong < len(stages) - 1:
print("\n")
msg = "Guess a letter"
char = input(msg)
if char in rletters:
cind = rletters.index(char)
board[cind] = char
rletters[cind] = '$'
else:
wrong += 1
print((" ".join(board)))
e = wrong + 1
print("\n".join(stages[0:e]))
if "__" not in board:
print("You win!")
print(" ".join(board))
win = True
break
if not win:
print("\n".join(stages[0:wrong]))
print("You lose! It was {}.".format(word))
hangman("cat")
\ No newline at end of file
# http://tinyurl.com/jv2rrl8
x = 2
y = 4
z = 8
xyz = x + y + z
xyz
\ No newline at end of file
# http://tinyurl.com/gldykam
rock = []
country = []
def collect_songs():
song = "Enter a song."
ask = "Type r or c. q to quit"
while True:
genre = input(ask)
if genre == "q":
break
if genre == "r":
rk = input(song)
rock.append(rk)
elif genre ==("c"):
cy = input(song)
country.append(cy)
else:
print("Invalid.")
print(rock)
print(country)
collect_songs()
\ No newline at end of file
# http://tinyurl.com/gu9jpco
a = 0
def increment():
global a
a += 1
\ No newline at end of file
# http://tinyurl.com/z27k2yl
def increment(a):
return a + 1
\ No newline at end of file
# http://tinyurl.com/zrmjape
class Orange:
def __init__(self):
print("Created!")
\ No newline at end of file
# http://tinyurl.com/hrf6cus
class Orange:
def __init__(self, w, c):
self.weight = w
self.color = c
print("Created!")
\ No newline at end of file
# http://tinyurl.com/jlc7pvk
class Orange:
def __init__(self, w, c):
self.weight = w
self.color = c
print("Created!")
or1 = Orange(10, "dark orange")
print(or1)
\ No newline at end of file
# http://tinyurl.com/grwzeo4
class Orange:
def __init__(self, w, c):
self.weight = w
self.color = c
print("Created!")
or1 = Orange(10, "dark orange")
print(or1.weight)
print(or1.color)
\ No newline at end of file
# http://tinyurl.com/jsxgw44
class Orange:
def __init__(self, w, c):
self.weight = w
self.color = c
print("Created!")
or1 = Orange(10, "dark orange")
or1.weight = 100
or1.color = "light orange"
print(or1.weight)
print(or1.color)
\ No newline at end of file
# http://tinyurl.com/jrmxlmo
class Orange:
def __init__(self, w, c):
self.weight = w
self.color = c
print("Created!")
or1 = Orange(4, "light orange")
or2 = Orange(8, "dark orange")
or3 = Orange(14, "yellow")
\ No newline at end of file
# http://tinyurl.com/zcp32pz
class Orange():
def __init__(self, w, c):
"""重量的单位是盎司"""
self.weight = w
self.color = c
self.mold = 0
print("Created!")
def rot(self, days, temp):
self.mold = days * temp
orange = Orange(6, "orange")
print(orange.mold)
orange.rot(10, 98)
print(orange.mold)
\ No newline at end of file
# http://tinyurl.com/j28qoox
class Rectangle():
def __init__(self, w, l):
self.width = w
self.len = l
def area(self):
return self.width * self.len
def change_size(self, w, l):
self.width = w
self.len = l
rectangle = Rectangle(10, 20)
print(rectangle.area())
rectangle.change_size(20, 40)
print(rectangle.area())
\ No newline at end of file
# http://tinyurl.com/j74o5rh
class Rectangle():
def __init__(self, w, l):
self.width = w
self.len = l
def area(self):
return self.width * self.len
\ No newline at end of file
# http://tinyurl.com/jtz28ha
class Data:
def __init__(self):
self.nums = [1, 2, 3, 4, 5]
def change_data(self, index, n):
self.nums[index] = n
\ No newline at end of file
# http://tinyurl.com/huczqr5
class Data:
def __init__(self):
self.nums = [1, 2, 3, 4, 5]
def change_data(self, index, n):
self.nums[index] = n
data_one = Data()
data_one.nums[0] = 100
print(data_one.nums)
data_two = Data()
data_two.change_data(0, 100)
print(data_two.nums)
\ No newline at end of file
# http://tinyurl.com/jkaorle
class PublicPrivateExample:
def __init__(self):
self.public = "safe"
self._unsafe = "unsafe"
def public_method(self):
# 客户端可以使用
pass
def _unsafe_method(self):
# 客户端不应使用
pass
\ No newline at end of file
# http://tinyurl.com/hrxd7gn
print("Hello, World!")
print(200)
print(200.1)
\ No newline at end of file
# http://tinyurl.com/gnxq24x
type("Hello, World!")
type(200)
type(200.1)
\ No newline at end of file
# 不要执行
# 未使用多态的代码画图
shapes = [trl, sql, crl]
for a_shape in shapes:
if type(a_shape) == "Triangle":
a_shape.draw_triangle()
if type(a_shape) == "Square":
a_shape.draw_square()
if type(a_shape) == "Circle":
a_shape.draw_cirlce()
# 使用多态的代码画图
shapes = [trl,
swl,
crl]
for a_shape in shapes:
a_shape.draw()
\ No newline at end of file
# http://tinyurl.com/zrnqeo3
class Shape():
def __init__(self, w, l):
self.width = w
self.len = l
def print_size(self):
print("""{} by {}
""".format(self.width,
self.len))
my_shape = Shape(20, 25)
my_shape.print_size()
\ No newline at end of file
# http://tinyurl.com/j8lj35s
class Shape():
def __init__(self, w, l):
self.width = w
self.len = l
def print_size(self):
print("""{} by {}
""".format(self.width,
self.len))
class Square(Shape):
pass
a_square = Square(20, 20)
a_square.print_size()
\ No newline at end of file
# http://tinyurl.com/hwjdcy9
class Shape():
def __init__(self, w, l):
self.width = w
self.len = l
def print_size(self):
print("""{} by {}
""".format(self.width,
self.len))
class Square(Shape):
def area(self):
return self.width * self.len
a_square = Square(20, 20)
print(a_square.area())
\ No newline at end of file
# http://tinyurl.com/hy9m8ht
class Shape():
def __init__(self, w, l):
self.width = w
self.len = l
def print_size(self):
print("""{} by {}
""".format(self.width,
self.len))
class Square(Shape):
def area(self):
return self.width * self.len
def print_size(self):
print("""I am {} by {}
""".format(self.width,
self.len))
a_square = Square(20, 20)
a_square.print_size()
\ No newline at end of file
# http://tinyurl.com/zqg488n
class Dog():
def __init__(self,
name,
breed,
owner):
self.name = name
self.breed = breed
self.owner = owner
class Person():
def __init__(self, name):
self.name = name
\ No newline at end of file
# http://tinyurl.com/zlzefd4
# 接上例
mick = Person("Mick Jagger")
stan = Dog("Stanley",
"Bulldog",
mick)
print(stan.owner.name)
\ No newline at end of file
# http://tinyurl.com/h7ypzmd
class Square:
pass
print(Square)
\ No newline at end of file
# http://tinyurl.com/zmnf47e
class Rectangle():
def __init__(self, w, l):
self.width = w
self.len = l
def print_size(self):
print("""{} by {}
""".format(self.width,
self.len))
my_rectangle = Rectangle(10, 24)
my_rectangle.print_size()
\ No newline at end of file
# http://tinyurl.com/gu9unfc
class Rectangle():
recs = []
def __init__(self, w, l):
self.width = w
self.len = l
self.recs.append((self.width,
self.len))
def print_size(self):
print("""{} by {}
""".format(self.width,
self.len))
r1 = Rectangle(10, 24)
r2 = Rectangle(20, 40)
r3 = Rectangle(100, 200)
print(Rectangle.recs)
\ No newline at end of file
# http://tinyurl.com/ze8yr7s
class Lion:
def __init__(self, name):
self.name = name
lion = Lion("Dilbert")
print(lion)
\ No newline at end of file
# http://tinyurl.com/j5rocqm
class Lion:
def __init__(self, name):
self.name = name
def __repr__(self):
return self.name
lion = Lion("Dilbert")
print(lion)
\ No newline at end of file
# http://tinyurl.com/hlmhrwv
class AlwaysPositive:
def __init__(self, number):
self.n = number
def __add__(self, other):
return abs(self.n +
other.n)
x = AlwaysPositive(-20)
y = AlwaysPositive(10)
print(x + y)
\ No newline at end of file
# http://tinyurl.com/gt28gww
class Person:
def __init__(self):
self.name = 'Bob'
bob = Person()
same_bob = bob
print(bob is same_bob)
another_bob = Person()
print(bob is another_bob)
\ No newline at end of file
# http://tinyurl.com/jjettn2
x = 10
if x is None:
print("x is None :( "
else:
print("x is not None")
x = None
if x is None:
print("x is None"
else:
print("x is None:(")
\ No newline at end of file
# http://tinyurl.com/jj22qv4
class Card:
suits = ["spades",
"hearts",
"diamonds",
"clubs"]
values = [None, None, "2", "3",
"4", "5", "6", "7",
"8", "9", "10",
"Jack", "Queen",
"King", "Ace" ]
def __init__(self, v, s):
"""suit 和 value 的值都为整型数"""
self.value = v
self.suit = s
def __lt__(self, c2):
if self.value < c2.value:
return True
if self.value == c2.value:
if self.suit < c2.suit:
return True
else:
return False
return False
def __gt__(self, c2):
if self.value > c2.value:
return True
if self.value == c2.value:
if self.suit > c2.suit:
return True
else:
return False
return False
def __repr__(self):
v = self.values[self.value] + " of " \
+ self.suits[self.suit]
return v
\ No newline at end of file
# http://tinyurl.com/j6donnr
card1 = Card(10, 2)
card2 = Card(11, 3)
print(card1 < card2)
\ No newline at end of file
# http://tinyurl.com/z57hc75
card = Card(3, 2)
print(card)
\ No newline at end of file
# http://tinyurl.com/jz8zfz7
from random import shuffle
class Deck:
def __init__(self):
self.cards = []
for i in range(2, 15):
for j in range(4):
self.cards.append(Card(i, j))
shuffle(self.cards)
def rm_card(self):
if len(self.cards) == 0:
return
return self.cards.pop()
\ No newline at end of file
# http://tinyurl.com/hsv5n6p
deck = Deck()
for card in deck.cards:
print(card)
\ No newline at end of file
# http://tinyurl.com/gwyrt2s
class Player:
def __init__(self, name):
self.wins = 0
self.card = None
self.name = name
\ No newline at end of file
# http://tinyurl.com/huwq8mw
class Game:
def __init__(self):
name1 = input("p1 name ")
name2 = input("p2 name ")
self.deck = Deck()
self.p1 = Player(name1)
self.p2 = Player(name2)
def wins(self, winner):
w = "{} wins this round"
w = w.format(winner)
print(w)
def draw(self, p1n, p1c, p2n, p2c):
d = "{} drew {} {} drew {}"
d = d.format(p1n, p1c, p2n, p2c)
print(d)
def play_game(self):
cards = self.deck.cards
print("beginning War!")
while len(cards) >= 2:
m = "q to quit. Any " + "key to play:"
response = input(m)
if response = "q":
break
p1c = self.deck.rm_card()
p2c = self.deck.rm_card()
p1n = self.p1.name
p2n = self.p2.name
self.draw(p1n, p1c, p2n, p2c)
if p1c > p2c:
self.p1.wins += 1
self.wins(self.p1.name)
else:
self.p2.wins += 1
self.wins(self.p2.name)
win = self.winner(self.p1, self.p2)
print("War is over. {} wins".format(win))
def winner(self, p1, p2):
if p1.wins > p2.wins:
return p1.name
if p1 wins < p2.wins:
return p2.name
return "It was a tie!"
\ No newline at end of file
# http://tinyurl.com/ho7364a
from random import shuffle
class Card:
suits = ["spades",
"hearts",
"diamonds",
"clubs"]
values = [None, None, "2", "3",
"4", "5", "6", "7",
"8", "9", "10",
"Jack", "Queen",
"King", "Ace" ]
def __init__(self, v, s):
"""suit 和 value 的值都为整型数"""
self.value = v
self.suit = s
def __lt__(self, c2):
if self.value < c2.value:
return True
if self.value == c2.value:
if self.suit < c2.suit:
return True
else:
return False
return False
def __gt__(self, c2):
if self.value > c2.value:
return True
if self.value == c2.value:
if self.suit > c2.suit:
return True
else:
return False
return False
def __repr__(self):
v = self.values[self.value] + " of " \
+ self.suits[self.suit]
return v
class Deck:
def __init__(self):
self.cards = []
for i in range(2, 15):
for j in range(4):
self.cards.append(Card(i, j))
shuffle(self.cards)
def rm_card(self):
if len(self.cards) == 0:
return
return self.cards.pop()
class Player:
def __init__(self, name):
self.wins = 0
self.card = None
self.name = name
class Game:
def __init__(self):
name1 = input("p1 name ")
name2 = input("p2 name ")
self.deck = Deck()
self.p1 = Player(name1)
self.p2 = Player(name2)
def wins(self, winner):
w = "{} wins this round"
w = w.format(winner)
print(w)
def draw(self, p1n, p1c, p2n, p2c):
d = "{} drew {} {} drew {}"
d = d.format(p1n, p1c, p2n, p2c)
print(d)
def play_game(self):
cards = self.deck.cards
print("beginning War!")
while len(cards) >= 2:
m = "q to quit. Any " + "key to play:"
response = input(m)
if response == 'q':
break
p1c = self.deck.rm_card()
p2c = self.deck.rm_card()
p1n = self.p1.name
p2n = self.p2.name
self.draw(p1n, p1c, p2n, p2c)
if p1c > p2c:
self.p1.wins += 1
self.wins(self.p1.name)
else:
self.p2.wins += 1
self.wins(self.p2.name)
win = self.winner(self.p1, self.p2)
print("War is over. {} wins".format(win))
def winner(self, p1, p2):
if p1.wins > p2.wins:
return p1.name
if p1 wins < p2.wins:
return p2.name
return "It was a tie!"
game = Game()
game.play_game()
\ No newline at end of file
# http://tinyurl.com/jjbc9v2
$ export x=100
$ echo $x
\ No newline at end of file
# http://tinyurl.com/j5wjwdf
$ echo $x
\ No newline at end of file
# http://tinyurl.com/junx62n
$ echo Hello, World!
\ No newline at end of file
# http://tinyurl.com/htoospk
$ python3
\ No newline at end of file
# http://tinyurl.com/jk2acua
print("Hello, World!")
\ No newline at end of file
# http://tinyurl.com/go2spbt
$ history
\ No newline at end of file
# http://tinyurl.com/hjgz79h
$ cd /
\ No newline at end of file
# http://tinyurl.com/j6ax35s
$ pwd
\ No newline at end of file
# http://tinyurl.com/gw4d5yw
$ ls
\ No newline at end of file
# http://tinyurl.com/zavhjeq
$ cd ~
$ mkdir tstp
\ No newline at end of file
# http://tinyurl.com/hneq2f6
$ ls
\ No newline at end of file
# http://tinyurl.com/zp3nb21
$ cd tstp
\ No newline at end of file
# http://tinyurl.com/z2gevk2
$ cd ..
\ No newline at end of file
# http://tinyurl.com/jkjjo6s
% rmdir tstp
\ No newline at end of file
# http://tinyurl.com/z32xn2n
$ ls
\ No newline at end of file
# http://tinyurl.com/j4y5kz4
$ ls -author
\ No newline at end of file
# http://tinyurl.com/hu9c54q
$ ls --author
\ No newline at end of file
# http://tinyurl.com/hfawo8t
$ touch .self_taught
\ No newline at end of file
# http://tinyurl.com/zjne9f5
$ ls | less
\ No newline at end of file
# http://tinyurl.com/z9prphe
$ export GREP_OPTIONS='--color=always'
$ export GREP_OPTIONS='--color=always'
\ No newline at end of file
# http://tinyurl.com/jgh3x4c
$ grep Beautiful zen.txt
\ No newline at end of file
# http://tinyurl.com/j2z6t2r
$ grep beautiful zen.txt
\ No newline at end of file
# http://tinyurl.com/zchmrdq
$ grep -i beautiful zen.txt
\ No newline at end of file
# http://tinyurl.com/zfcdnmx
$ grep -o Beautiful zen.txt
\ No newline at end of file
# http://tinyurl.com/z9q2286
import re
l = "Beautiful is better than ugly."
matches = re.findall("Beautiful", l)
print(matches)
\ No newline at end of file
# http://tinyurl.com/jzeonne
import re
l = "Beautiful is better than ugly."
matches = re.findall("beautiful",
l,
re.IGNORECASE)
print(matches)
\ No newline at end of file
# http://tinyurl.com/gleyzan
$ grep ^If zen.txt
\ No newline at end of file
# http://tinyurl.com/zkvpc2r
$ grep idea.$ zen.txt
\ No newline at end of file
# http://tinyurl.com/zntqzc9
import re
zen = """Although never is
often better than
*right* now.
If the implementation
is hard to explain,
it's a bad idea.
If the implementation
is easy to explain,
it may be a good
idea. Namesapces
are one honking
great idea -- let's
do more of those!
"""
m = re.findall("^If",
zen,
re.MULITILINE)
print(m)
\ No newline at end of file
# http://tinyurl.com/jf9qzuz
$ echo Two too. | grep -i t[ow]o
\ No newline at end of file
# http://tinyurl.com/hg9sw3u
import re
string = "Two too."
m = re.findall("t[ow]o",
string,
re.IGNORECASE)
print(m)
\ No newline at end of file
# http://tinyurl.com/gm8o6gb
$ echo 123 hi 34 hello. | grep [[:digit:]]
\ No newline at end of file
# http://tinyurl.com/z3hr4q8
import re
line = "123?34 hello?"
m = re.findall("\d",
line,
re.IGNORECASE)
print(m)
\ No newline at end of file
# http://tinyurl.com/j8vbwq8
$ echo two twoo not too. | grep -o two*
\ No newline at end of file
# http://tinyurl.com/h5x6cal
$ echo __hello__there | grep -o __.*__
\ No newline at end of file
# http://tinyurl.com/j9v9t24
$ echo __hi__bye__hi__there | grep -o __.*__
\ No newline at end of file
# http://tinyurl.com/j399sq9
import re
t = "__one__ __two__ __three__"
found = re.findall("__.*?__", t)
for match in found:
print(match)
\ No newline at end of file
# http://tinyurl.com/ze6oyua
import re
text = """Giraffes have aroused
the curiosity of __PLURAL_NOUN__
since earliest times. The
giraffe is the tallest of all
living __PLURAL_NOUN__, but
scientists are unable to
explain how it got its long
__PART_OF_THE_BODY__. The
giraffe's tremendous height,
which might reach __NUMBER__
__PLURAL_NOUN__, comes from
it legs and __BODYPART__.
"""
def mad_libs(mls):
"""
:param mls:字符串
双下划线部分的内容要由玩家来补充。
双下划线不能出现在提示语中,如不能
出现 __hint_hint__,只能是 __hint__。
"""
hints = re.findall("__.*?__",
mls)
if hints is not None:
for word in hints:
q = "Enter a {}".format(word)
new = input(q)
mls = mls.replace(word, new, 1)
print("\n")
mls = mls.replace("\n", "")
print(mls)
else:
print("invalid mls")
mad_libs(text)
\ No newline at end of file
# http://tinyurl.com/zkbumfj
$ echo I love $ | grep \\$
\ No newline at end of file
# http://tinyurl.com/zy7pr41
import re
line = "I love $"
m = re.findall("\\$",
line,
re.IGNORECASE)
print(m)
\ No newline at end of file
# http://tinyurl.com/hmookdf
$ pip
\ No newline at end of file
# http://tinyurl.com/hchso7u
$ sudo pip install Flask==0.11.1
\ No newline at end of file
# http://tinyurl.com/hyxm3vt
$ pip install Flask==0.11.1
\ No newline at end of file
# http://tinyurl.com/h59sdyu
from flask import Flask
app = Flask(__name__)
@app.route('/')
def index():
return "Hello, World!"
app.run(port='8000')
\ No newline at end of file
# http://tinyurl.com/zxgcqeh
pip freeze
\ No newline at end of file
# http://tinyurl.com/ht8mleo
pip uninstall flask.
...
\ No newline at end of file
# http://tinyurl.com/gs9d5hf
$ git
\ No newline at end of file
# http://tinyurl.com/hvmq98m
$ git clone [仓库链接]
\ No newline at end of file
# http://tinyurl.com/gp4o9qv
$ ls
\ No newline at end of file
# http://tinyurl.com/jscq6pj
$ cd hangman
$ git remote -v
\ No newline at end of file
# http://tinyurl.com/jvcr59w
$ git status
\ No newline at end of file
# http://tinyurl.com/hncnyz9
$ git add hangman.py
\ No newline at end of file
# http://tinyurl.com/jeuug7j
$ git status
\ No newline at end of file
# http://tinyurl.com/hh6xxvw
$ git reset hangman.py.
\ No newline at end of file
# http://tinyurl.com/gowe7hp
$ git add hangman.py
$ git status
\ No newline at end of file
# http://tinyurl.com/gmn92p6
$ git commit -m "my first commit"
\ No newline at end of file
# http://tinyurl.com/hy98yq9
$ git push origin master
\ No newline at end of file
# http://tinyurl.com/gqf2xue
$ git pull origin master
\ No newline at end of file
# http://tinyurl.com/h2m7ahs
$ git log
\ No newline at end of file
# http://tinyurl.com/h6msygd
$ git add hello_world.py
\ No newline at end of file
# http://tinyurl.com/zg4d8vd
$ git status
\ No newline at end of file
# http://tinyurl.com/ztcm8zs
$ git commit -m "adding new file"
\ No newline at end of file
# http://tinyurl.com/zay2vct
$ git push origin master
\ No newline at end of file
# http://tinyurl.com/znvj9r8
$ git diff hello_world.py
\ No newline at end of file
# http://tinyurl.com/jptzkvp
My Website
Hello, World!
click here
\ No newline at end of file
# http://tinyurl.com/z4fzfzf
$ sudo pip install beautifulsoup4==4.4.1
\ No newline at end of file
# http://tinyurl.com/hk3kxgr
$ pip install beautifulsoup4==4.4.1
\ No newline at end of file
# http://tinyurl.com/jmgyar8
import urllib.request
from bs4 import BeautifulSoup
class Scraper:
def __init__(self,
site):
self.site = site
def scrape(self):
pass
\ No newline at end of file
# http://tinyurl.com/h5eywoa
def scrape(self):
r = urllib.request.urlopen(self.site)
html = r.read()
\ No newline at end of file
# http://tinyurl.com/hyjulxh
def scrape(self):
r = urllib.request.urlopen(self.site)
html = r.read()
parser = "html.parser"
sp = BeautifulSoup(html, parser)
\ No newline at end of file
# http://tinyurl.com/zwrxjjk
def scrape(self):
r = urllib.request.urlopen(self.site)
html = r.read()
parser = "html.parser"
sp = BeautifulSoup(html, parser)
for tag in sp.find_all("a"):
url = tag.get("href")
if url is None:
continue
if "html" in url:
print("\n" + url)
\ No newline at end of file
# http://tinyurl.com/j55s7hm
import urllib.request
from bs4 import BeautifulSoup
class Scraper:
def __init__(self, site):
self.site = site
def scrape(self):
r = urllib.request.urlopen(self.site)
html = r.read()
parser = "html.parser"
sp = BeautifulSoup(html, parser)
for tag in sp.find_all("a"):
url = tag.get("href")
if url is None:
continue
if "html" in url:
print("\n" + url)
news = "https://news.google.com/"
Scraper(news).scrape()
\ No newline at end of file
https://www.washingtonpost.com/world/national-security/in-foreign-bribery-cases-leniency-offered-to-companies-that-turn-over-employees/2016/04/05/d7a24d94-fb43-11e5-9140-e61d062438bb_story.html
http://www.appeal-democrat.com/news/unit-apartment-complex-proposed-in-marysville/article_bd6ea9f2-fac3-11e5-bfaf-4fbe11089e5a.html
http://www.appeal-democrat.com/news/injuries-from-yuba-city-bar-violence-hospitalize-groom-to-be/article_03e46648-f54b-11e5-96b3-5bf32bfbf2b5.html
\ No newline at end of file
# http://tinyurl.com/zk24ps6
class Stack:
def __init__(self):
self.items = []
def is_empty(self):
return self.items == []
def push(self, item):
self.items.append(item)
def pop(self):
return self.items.pop()
def peek(self):
last = len(self.items)-1
return self.items[last]
def size(self):
return len(self.items)
\ No newline at end of file
# http://tinyurl.com/jfybm4v
stack = Stack()
print(stack.is_empty())
\ No newline at end of file
# http://tinyurl.com/zsexcal
stack = Stack()
stack.push(1)
print(stack.is_empty())
\ No newline at end of file
# http://tinyurl.com/j72kswr
stack = Stack()
stack.push(1)
item = stack.pop()
print(item)
print(stack.is_empty())
\ No newline at end of file
# http://tinyurl.com/zle7sno
stack = Stack()
for i in range(0, 6):
stack.push(i)
print(stack.peek())
print(stack.size())
\ No newline at end of file
# http://tinyurl.com/zoosvqg
class Stack:
def __init__(self):
self.items = []
def is_empty(self):
return self.items == []
def push(self, item):
self.items.append(item)
def pop(self):
return self.items.pop()
def peek(self):
last = len(self.items)-1
return self.items[last]
def size(self):
return len(self.items)
stack = Stack()
for c in "Hello":
stack.push(c)
reverse = ""
for i in range(len(stack.items)):
reverse += stack.pop()
print(reverse)
\ No newline at end of file
# http://tinyurl.com/zrg24hj
class Queue:
def __init__(self):
self.items = []
def is_empty(self):
return self.items == []
def enqueue(self, item):
self.items.insert(0, item)
def dequeue(self):
return self.items.pop()
def size(self):
return len(self.items)
\ No newline at end of file
# http://tinyurl.com/j3ck9jl
a_queue = Queue()
print(a_queue.is_empty())
\ No newline at end of file
# http://tinyurl.com/jzjrg8s
a_queue = Queue()
for i in range(5):
a_queue.enqueue(i)
print(a_queue.size())
\ No newline at end of file
# http://tinyurl.com/jazkh8b
a_queue = Queue()
for i in range(5):
a_queue.enqueue(i)
for i in range(5):
print(a_queue.dequeue())
print()
print(a_queue.size())
\ No newline at end of file
# http://tinyurl.com/jnw56zx
import time
import random
class Queue:
def __init__(self):
self.items = []
def is_empty(self):
return self.items == []
def enqueue(self, item):
self.items.insert(0, item)
def dequeue(self):
return self.items.pop()
def size(self):
return len(self.items)
def simulate_line(self, till_show, max_time):
pq = Queue()
tix_sold = []
for i in range(10):
pq.enqueue("person" + str(i))
t_end = time.time() + till_show
now = time.time()
while now < t_end and not pq.is_empty():
now = time.time()
r = random.randint(0, max_time)
time.sleep(r)
person = pq.dequeue()
print(person)
tix_sold.append(person)
return tix_sold
queue = Queue()
sold = queue.simulate_line(5, 1)
print(sold)
\ No newline at end of file
# http://tinyurl.com/jroprmn
def fizz_buzz():
for i in range(1, 101):
if i % 3 == 0 and i % 5 == 0:
print("FizzBuzz")
elif i % 3 == 0:
print("Fizz")
elif i % 5 == 0:
print("Buzz")
else:
print(i)
fizz_buzz()
\ No newline at end of file
# http://tinyurl.com/zer9esp
def ss(number_list, n):
found = False
for i in number_list:
if i == n:
found = True
break
return found
numbers = range(0, 100)
s1 = ss(numbers, 2)
print(s1)
s2 = ss(numbers, 202)
print(s2)
\ No newline at end of file
# http://tinyurl.com/jffr7pr
def palindrome(word):
word = word.lower()
return word[::-1] == word
print(palindrome("Mother"))
print(palindrome("Mom"))
\ No newline at end of file
# http://tinyurl.com/hxplj3z
def anagram(w1, w2):
w1 = w1.lower()
w2 = w2.lower()
return sorted(w1) == sorted(w2)
print(anagram("iceman", "cinema"))
print(anagram("leaf", "tree"))
\ No newline at end of file
# http://tinyurl.com/zknqlde
def count_characters(string):
count_dict = {}
for c in string:
if c in count_dict:
count_dict[c] += 1
else:
count_dict[c] = 1
print(count_dict)
count_characters("Dynasty")
\ No newline at end of file
# http://tinyurl.com/z49qe4s
def bottles_of_beer(bob):
""" Prints 99 Bottle
of Beer on the
Wall lyrics.
:param bob: Must
be a positive
integer.
"""
if bob < 1:
print("""No more
bottles
of beer
on the wall.
No more
bottles of
beer.""")
return
tmp = bob
bob -= 1
print("""{} bottles of
beer on the
wall. {} bottles
of beer. Take one
down, pass it
around, {} bottles
of beer on the
wall.
""".format(tmp,
tmp,
bob))
bottles_of_beer(bob)
bottles_of_beer(99)
\ No newline at end of file
# http://tinyurl.com/h4k3ytt
if bob < 1:
print("""No more
bottles
of beer
on the wall.
No more
bottles of
beer.""")
return
\ No newline at end of file
# http://tinyurl.com/j7zwm8t
bottles_of_beer(bob)
\ No newline at end of file
{
"data/books/1.Python编程无师自通/第22章 算法/22.2 顺序搜索/code_1.py": "https://bbs.csdn.net/topics/603857479",
"data/books/1.Python编程无师自通/第22章 算法/22.1 FizzBuzz/code_1.py": "https://bbs.csdn.net/topics/603857480",
"data/books/1.Python编程无师自通/第22章 算法/22.6 递归/code_1.py": "https://bbs.csdn.net/topics/603857653",
"data/books/1.Python编程无师自通/第22章 算法/22.6 递归/code_2.py": "https://bbs.csdn.net/topics/603857740",
"data/books/1.Python编程无师自通/第22章 算法/22.6 递归/code_3.py": "https://bbs.csdn.net/topics/603857654",
"data/books/1.Python编程无师自通/第22章 算法/22.3 回文词/code_1.py": "https://bbs.csdn.net/topics/603857590",
"data/books/1.Python编程无师自通/第22章 算法/22.4 变位词/code_1.py": "https://bbs.csdn.net/topics/603857741",
"data/books/1.Python编程无师自通/第22章 算法/22.5 计算字母频数/code_1.py": "https://bbs.csdn.net/topics/603857591",
"data/books/1.Python编程无师自通/第20章 融会贯通/20.2 爬取Google新闻/code_4.py": "https://bbs.csdn.net/topics/603857481",
"data/books/1.Python编程无师自通/第20章 融会贯通/20.2 爬取Google新闻/code_1.py": "https://bbs.csdn.net/topics/603857592",
"data/books/1.Python编程无师自通/第20章 融会贯通/20.2 爬取Google新闻/code_5.py": "https://bbs.csdn.net/topics/603857482",
"data/books/1.Python编程无师自通/第20章 融会贯通/20.2 爬取Google新闻/code_2.py": "https://bbs.csdn.net/topics/603857655",
"data/books/1.Python编程无师自通/第20章 融会贯通/20.2 爬取Google新闻/code_6.py": "https://bbs.csdn.net/topics/603857593",
"data/books/1.Python编程无师自通/第20章 融会贯通/20.2 爬取Google新闻/code_7.py": "https://bbs.csdn.net/topics/603857742",
"data/books/1.Python编程无师自通/第20章 融会贯通/20.2 爬取Google新闻/code_3.py": "https://bbs.csdn.net/topics/603857743",
"data/books/1.Python编程无师自通/第20章 融会贯通/20.2 爬取Google新闻/code_8.py": "https://bbs.csdn.net/topics/603857483",
"data/books/1.Python编程无师自通/第20章 融会贯通/20.1 HTML/code_1.py": "https://bbs.csdn.net/topics/603857656",
"data/books/1.Python编程无师自通/第10章 综合练习/10.1 Hangman/code_4.py": "https://bbs.csdn.net/topics/603857657",
"data/books/1.Python编程无师自通/第10章 综合练习/10.1 Hangman/code_1.py": "https://bbs.csdn.net/topics/603857658",
"data/books/1.Python编程无师自通/第10章 综合练习/10.1 Hangman/code_2.py": "https://bbs.csdn.net/topics/603857744",
"data/books/1.Python编程无师自通/第10章 综合练习/10.1 Hangman/code_3.py": "https://bbs.csdn.net/topics/603857659",
"data/books/1.Python编程无师自通/第18章 包管理器/18.2 pip/code_4.py": "https://bbs.csdn.net/topics/603857484",
"data/books/1.Python编程无师自通/第18章 包管理器/18.2 pip/code_1.py": "https://bbs.csdn.net/topics/603857594",
"data/books/1.Python编程无师自通/第18章 包管理器/18.2 pip/code_5.py": "https://bbs.csdn.net/topics/603857660",
"data/books/1.Python编程无师自通/第18章 包管理器/18.2 pip/code_2.py": "https://bbs.csdn.net/topics/603857595",
"data/books/1.Python编程无师自通/第18章 包管理器/18.2 pip/code_6.py": "https://bbs.csdn.net/topics/603857661",
"data/books/1.Python编程无师自通/第18章 包管理器/18.2 pip/code_3.py": "https://bbs.csdn.net/topics/603857745",
"data/books/1.Python编程无师自通/第06章 字符串操作/6.13 in关键字/code_1.py": "https://bbs.csdn.net/topics/603857596",
"data/books/1.Python编程无师自通/第06章 字符串操作/6.13 in关键字/code_2.py": "https://bbs.csdn.net/topics/603857485",
"data/books/1.Python编程无师自通/第06章 字符串操作/6.4 字符串拼接/code_1.py": "https://bbs.csdn.net/topics/603857746",
"data/books/1.Python编程无师自通/第06章 字符串操作/6.3 字符串是不可变的/code_1.py": "https://bbs.csdn.net/topics/603857662",
"data/books/1.Python编程无师自通/第06章 字符串操作/6.5 字符串乘法/code_1.py": "https://bbs.csdn.net/topics/603857486",
"data/books/1.Python编程无师自通/第06章 字符串操作/6.12 查找索引/code_1.py": "https://bbs.csdn.net/topics/603857487",
"data/books/1.Python编程无师自通/第06章 字符串操作/6.12 查找索引/code_2.py": "https://bbs.csdn.net/topics/603857597",
"data/books/1.Python编程无师自通/第06章 字符串操作/6.12 查找索引/code_3.py": "https://bbs.csdn.net/topics/603857598",
"data/books/1.Python编程无师自通/第06章 字符串操作/6.15 换行符/code_1.py": "https://bbs.csdn.net/topics/603857663",
"data/books/1.Python编程无师自通/第06章 字符串操作/6.16 切片/code_4.py": "https://bbs.csdn.net/topics/603857664",
"data/books/1.Python编程无师自通/第06章 字符串操作/6.16 切片/code_1.py": "https://bbs.csdn.net/topics/603857747",
"data/books/1.Python编程无师自通/第06章 字符串操作/6.16 切片/code_5.py": "https://bbs.csdn.net/topics/603857488",
"data/books/1.Python编程无师自通/第06章 字符串操作/6.16 切片/code_2.py": "https://bbs.csdn.net/topics/603857748",
"data/books/1.Python编程无师自通/第06章 字符串操作/6.16 切片/code_3.py": "https://bbs.csdn.net/topics/603857489",
"data/books/1.Python编程无师自通/第06章 字符串操作/6.1 三引号字符串/code_1.py": "https://bbs.csdn.net/topics/603857599",
"data/books/1.Python编程无师自通/第06章 字符串操作/6.6 改变大小写/code_1.py": "https://bbs.csdn.net/topics/603857665",
"data/books/1.Python编程无师自通/第06章 字符串操作/6.6 改变大小写/code_2.py": "https://bbs.csdn.net/topics/603857490",
"data/books/1.Python编程无师自通/第06章 字符串操作/6.6 改变大小写/code_3.py": "https://bbs.csdn.net/topics/603857491",
"data/books/1.Python编程无师自通/第06章 字符串操作/6.2 索引/code_4.py": "https://bbs.csdn.net/topics/603857666",
"data/books/1.Python编程无师自通/第06章 字符串操作/6.2 索引/code_1.py": "https://bbs.csdn.net/topics/603857749",
"data/books/1.Python编程无师自通/第06章 字符串操作/6.2 索引/code_2.py": "https://bbs.csdn.net/topics/603857492",
"data/books/1.Python编程无师自通/第06章 字符串操作/6.2 索引/code_3.py": "https://bbs.csdn.net/topics/603857667",
"data/books/1.Python编程无师自通/第06章 字符串操作/6.7 格式化/code_4.py": "https://bbs.csdn.net/topics/603857750",
"data/books/1.Python编程无师自通/第06章 字符串操作/6.7 格式化/code_1.py": "https://bbs.csdn.net/topics/603857800",
"data/books/1.Python编程无师自通/第06章 字符串操作/6.7 格式化/code_2.py": "https://bbs.csdn.net/topics/603857751",
"data/books/1.Python编程无师自通/第06章 字符串操作/6.7 格式化/code_3.py": "https://bbs.csdn.net/topics/603857752",
"data/books/1.Python编程无师自通/第06章 字符串操作/6.11 替换/code_1.py": "https://bbs.csdn.net/topics/603857753",
"data/books/1.Python编程无师自通/第06章 字符串操作/6.8 分割/code_1.py": "https://bbs.csdn.net/topics/603857668",
"data/books/1.Python编程无师自通/第06章 字符串操作/6.14 字符串转义/code_4.py": "https://bbs.csdn.net/topics/603857801",
"data/books/1.Python编程无师自通/第06章 字符串操作/6.14 字符串转义/code_1.py": "https://bbs.csdn.net/topics/603857802",
"data/books/1.Python编程无师自通/第06章 字符串操作/6.14 字符串转义/code_2.py": "https://bbs.csdn.net/topics/603857493",
"data/books/1.Python编程无师自通/第06章 字符串操作/6.14 字符串转义/code_3.py": "https://bbs.csdn.net/topics/603857754",
"data/books/1.Python编程无师自通/第06章 字符串操作/6.10 去除空格/code_1.py": "https://bbs.csdn.net/topics/603857669",
"data/books/1.Python编程无师自通/第06章 字符串操作/6.9 连接/code_1.py": "https://bbs.csdn.net/topics/603857670",
"data/books/1.Python编程无师自通/第06章 字符串操作/6.9 连接/code_2.py": "https://bbs.csdn.net/topics/603857755",
"data/books/1.Python编程无师自通/第06章 字符串操作/6.9 连接/code_3.py": "https://bbs.csdn.net/topics/603857494",
"data/books/1.Python编程无师自通/第03章 编程概论/code_0.py": "https://bbs.csdn.net/topics/603857671",
"data/books/1.Python编程无师自通/第03章 编程概论/3.9 语法/code_1.py": "https://bbs.csdn.net/topics/603857803",
"data/books/1.Python编程无师自通/第03章 编程概论/3.11 算术操作符/code_4.py": "https://bbs.csdn.net/topics/603857756",
"data/books/1.Python编程无师自通/第03章 编程概论/3.11 算术操作符/code_1.py": "https://bbs.csdn.net/topics/603857672",
"data/books/1.Python编程无师自通/第03章 编程概论/3.11 算术操作符/code_5.py": "https://bbs.csdn.net/topics/603857673",
"data/books/1.Python编程无师自通/第03章 编程概论/3.11 算术操作符/code_2.py": "https://bbs.csdn.net/topics/603857674",
"data/books/1.Python编程无师自通/第03章 编程概论/3.11 算术操作符/code_6.py": "https://bbs.csdn.net/topics/603857757",
"data/books/1.Python编程无师自通/第03章 编程概论/3.11 算术操作符/code_3.py": "https://bbs.csdn.net/topics/603857495",
"data/books/1.Python编程无师自通/第03章 编程概论/3.2 注释/code_1.py": "https://bbs.csdn.net/topics/603857804",
"data/books/1.Python编程无师自通/第03章 编程概论/3.2 注释/code_2.py": "https://bbs.csdn.net/topics/603857758",
"data/books/1.Python编程无师自通/第03章 编程概论/3.2 注释/code_3.py": "https://bbs.csdn.net/topics/603857675",
"data/books/1.Python编程无师自通/第03章 编程概论/3.12 比较操作符/code_4.py": "https://bbs.csdn.net/topics/603857759",
"data/books/1.Python编程无师自通/第03章 编程概论/3.12 比较操作符/code_1.py": "https://bbs.csdn.net/topics/603857496",
"data/books/1.Python编程无师自通/第03章 编程概论/3.12 比较操作符/code_5.py": "https://bbs.csdn.net/topics/603857805",
"data/books/1.Python编程无师自通/第03章 编程概论/3.12 比较操作符/code_2.py": "https://bbs.csdn.net/topics/603857676",
"data/books/1.Python编程无师自通/第03章 编程概论/3.12 比较操作符/code_6.py": "https://bbs.csdn.net/topics/603857806",
"data/books/1.Python编程无师自通/第03章 编程概论/3.12 比较操作符/code_3.py": "https://bbs.csdn.net/topics/603857760",
"data/books/1.Python编程无师自通/第03章 编程概论/3.8 常量和变量/code_4.py": "https://bbs.csdn.net/topics/603857497",
"data/books/1.Python编程无师自通/第03章 编程概论/3.8 常量和变量/code_1.py": "https://bbs.csdn.net/topics/603857677",
"data/books/1.Python编程无师自通/第03章 编程概论/3.8 常量和变量/code_5.py": "https://bbs.csdn.net/topics/603857498",
"data/books/1.Python编程无师自通/第03章 编程概论/3.8 常量和变量/code_2.py": "https://bbs.csdn.net/topics/603857678",
"data/books/1.Python编程无师自通/第03章 编程概论/3.8 常量和变量/code_6.py": "https://bbs.csdn.net/topics/603857761",
"data/books/1.Python编程无师自通/第03章 编程概论/3.8 常量和变量/code_7.py": "https://bbs.csdn.net/topics/603857807",
"data/books/1.Python编程无师自通/第03章 编程概论/3.8 常量和变量/code_3.py": "https://bbs.csdn.net/topics/603857679",
"data/books/1.Python编程无师自通/第03章 编程概论/3.8 常量和变量/code_8.py": "https://bbs.csdn.net/topics/603857762",
"data/books/1.Python编程无师自通/第03章 编程概论/3.8 常量和变量/code_9.py": "https://bbs.csdn.net/topics/603857808",
"data/books/1.Python编程无师自通/第03章 编程概论/3.4 代码行/code_1.py": "https://bbs.csdn.net/topics/603857809",
"data/books/1.Python编程无师自通/第03章 编程概论/3.4 代码行/code_2.py": "https://bbs.csdn.net/topics/603857763",
"data/books/1.Python编程无师自通/第03章 编程概论/3.4 代码行/code_3.py": "https://bbs.csdn.net/topics/603857680",
"data/books/1.Python编程无师自通/第03章 编程概论/3.7 数据类型/code_4.py": "https://bbs.csdn.net/topics/603857810",
"data/books/1.Python编程无师自通/第03章 编程概论/3.7 数据类型/code_1.py": "https://bbs.csdn.net/topics/603857811",
"data/books/1.Python编程无师自通/第03章 编程概论/3.7 数据类型/code_2.py": "https://bbs.csdn.net/topics/603857764",
"data/books/1.Python编程无师自通/第03章 编程概论/3.7 数据类型/code_3.py": "https://bbs.csdn.net/topics/603857681",
"data/books/1.Python编程无师自通/第03章 编程概论/3.13 逻辑操作符/code_4.py": "https://bbs.csdn.net/topics/603857812",
"data/books/1.Python编程无师自通/第03章 编程概论/3.13 逻辑操作符/code_1.py": "https://bbs.csdn.net/topics/603857499",
"data/books/1.Python编程无师自通/第03章 编程概论/3.13 逻辑操作符/code_5.py": "https://bbs.csdn.net/topics/603857765",
"data/books/1.Python编程无师自通/第03章 编程概论/3.13 逻辑操作符/code_2.py": "https://bbs.csdn.net/topics/603857900",
"data/books/1.Python编程无师自通/第03章 编程概论/3.13 逻辑操作符/code_3.py": "https://bbs.csdn.net/topics/603857682",
"data/books/1.Python编程无师自通/第03章 编程概论/3.14 条件语句/code_4.py": "https://bbs.csdn.net/topics/603857901",
"data/books/1.Python编程无师自通/第03章 编程概论/3.14 条件语句/code_1.py": "https://bbs.csdn.net/topics/603857813",
"data/books/1.Python编程无师自通/第03章 编程概论/3.14 条件语句/code_5.py": "https://bbs.csdn.net/topics/603857766",
"data/books/1.Python编程无师自通/第03章 编程概论/3.14 条件语句/code_2.py": "https://bbs.csdn.net/topics/603857902",
"data/books/1.Python编程无师自通/第03章 编程概论/3.14 条件语句/code_6.py": "https://bbs.csdn.net/topics/603857903",
"data/books/1.Python编程无师自通/第03章 编程概论/3.14 条件语句/code_7.py": "https://bbs.csdn.net/topics/603857814",
"data/books/1.Python编程无师自通/第03章 编程概论/3.14 条件语句/code_3.py": "https://bbs.csdn.net/topics/603857683",
"data/books/1.Python编程无师自通/第03章 编程概论/3.14 条件语句/code_8.py": "https://bbs.csdn.net/topics/603857815",
"data/books/1.Python编程无师自通/第03章 编程概论/3.14 条件语句/code_9.py": "https://bbs.csdn.net/topics/603857684",
"data/books/1.Python编程无师自通/第03章 编程概论/3.3 打印/code_1.py": "https://bbs.csdn.net/topics/603857685",
"data/books/1.Python编程无师自通/第03章 编程概论/3.15 语句/code_4.py": "https://bbs.csdn.net/topics/603857767",
"data/books/1.Python编程无师自通/第03章 编程概论/3.15 语句/code_1.py": "https://bbs.csdn.net/topics/603857904",
"data/books/1.Python编程无师自通/第03章 编程概论/3.15 语句/code_2.py": "https://bbs.csdn.net/topics/603857905",
"data/books/1.Python编程无师自通/第03章 编程概论/3.15 语句/code_3.py": "https://bbs.csdn.net/topics/603857906",
"data/books/1.Python编程无师自通/第03章 编程概论/3.10 错误与异常/code_1.py": "https://bbs.csdn.net/topics/603857907",
"data/books/1.Python编程无师自通/第03章 编程概论/3.10 错误与异常/code_2.py": "https://bbs.csdn.net/topics/603857686",
"data/books/1.Python编程无师自通/第03章 编程概论/3.10 错误与异常/code_3.py": "https://bbs.csdn.net/topics/603857687",
"data/books/1.Python编程无师自通/第03章 编程概论/3.6 间距/code_1.py": "https://bbs.csdn.net/topics/603857768",
"data/books/1.Python编程无师自通/第03章 编程概论/3.6 间距/code_2.py": "https://bbs.csdn.net/topics/603857769",
"data/books/1.Python编程无师自通/第03章 编程概论/3.1 示例/code_1.py": "https://bbs.csdn.net/topics/603857908",
"data/books/1.Python编程无师自通/第09章 文件/9.1 写文件操作/code_1.py": "https://bbs.csdn.net/topics/603857909",
"data/books/1.Python编程无师自通/第09章 文件/9.1 写文件操作/code_2.py": "https://bbs.csdn.net/topics/603857770",
"data/books/1.Python编程无师自通/第09章 文件/9.4 CSV文件/code_1.py": "https://bbs.csdn.net/topics/603857816",
"data/books/1.Python编程无师自通/第09章 文件/9.4 CSV文件/code_2.py": "https://bbs.csdn.net/topics/603857817",
"data/books/1.Python编程无师自通/第09章 文件/9.2 自动关闭文件/code_1.py": "https://bbs.csdn.net/topics/603857818",
"data/books/1.Python编程无师自通/第09章 文件/9.3 读取文件/code_1.py": "https://bbs.csdn.net/topics/603857688",
"data/books/1.Python编程无师自通/第09章 文件/9.3 读取文件/code_2.py": "https://bbs.csdn.net/topics/603857689",
"data/books/1.Python编程无师自通/第12章 编程范式/12.2 过程式编程/code_1.py": "https://bbs.csdn.net/topics/603857910",
"data/books/1.Python编程无师自通/第12章 编程范式/12.2 过程式编程/code_2.py": "https://bbs.csdn.net/topics/603857819",
"data/books/1.Python编程无师自通/第12章 编程范式/12.3 函数式编程/code_1.py": "https://bbs.csdn.net/topics/603857690",
"data/books/1.Python编程无师自通/第12章 编程范式/12.3 函数式编程/code_2.py": "https://bbs.csdn.net/topics/603857771",
"data/books/1.Python编程无师自通/第12章 编程范式/12.4 面向对象编程/code_4.py": "https://bbs.csdn.net/topics/603857691",
"data/books/1.Python编程无师自通/第12章 编程范式/12.4 面向对象编程/code_1.py": "https://bbs.csdn.net/topics/603857692",
"data/books/1.Python编程无师自通/第12章 编程范式/12.4 面向对象编程/code_5.py": "https://bbs.csdn.net/topics/603857911",
"data/books/1.Python编程无师自通/第12章 编程范式/12.4 面向对象编程/code_2.py": "https://bbs.csdn.net/topics/603857772",
"data/books/1.Python编程无师自通/第12章 编程范式/12.4 面向对象编程/code_6.py": "https://bbs.csdn.net/topics/603857912",
"data/books/1.Python编程无师自通/第12章 编程范式/12.4 面向对象编程/code_7.py": "https://bbs.csdn.net/topics/603857820",
"data/books/1.Python编程无师自通/第12章 编程范式/12.4 面向对象编程/code_3.py": "https://bbs.csdn.net/topics/603857773",
"data/books/1.Python编程无师自通/第12章 编程范式/12.4 面向对象编程/code_8.py": "https://bbs.csdn.net/topics/603857774",
"data/books/1.Python编程无师自通/第08章 模块/8.2 导入其他模块/code_4.py": "https://bbs.csdn.net/topics/603857693",
"data/books/1.Python编程无师自通/第08章 模块/8.2 导入其他模块/code_1.py": "https://bbs.csdn.net/topics/603857913",
"data/books/1.Python编程无师自通/第08章 模块/8.2 导入其他模块/code_5.py": "https://bbs.csdn.net/topics/603857694",
"data/books/1.Python编程无师自通/第08章 模块/8.2 导入其他模块/code_2.py": "https://bbs.csdn.net/topics/603857914",
"data/books/1.Python编程无师自通/第08章 模块/8.2 导入其他模块/code_6.py": "https://bbs.csdn.net/topics/603857775",
"data/books/1.Python编程无师自通/第08章 模块/8.2 导入其他模块/code_3.py": "https://bbs.csdn.net/topics/603857776",
"data/books/1.Python编程无师自通/第08章 模块/8.1 导入内置模块/code_4.py": "https://bbs.csdn.net/topics/603857821",
"data/books/1.Python编程无师自通/第08章 模块/8.1 导入内置模块/code_1.py": "https://bbs.csdn.net/topics/603857695",
"data/books/1.Python编程无师自通/第08章 模块/8.1 导入内置模块/code_5.py": "https://bbs.csdn.net/topics/603857822",
"data/books/1.Python编程无师自通/第08章 模块/8.1 导入内置模块/code_2.py": "https://bbs.csdn.net/topics/603857823",
"data/books/1.Python编程无师自通/第08章 模块/8.1 导入内置模块/code_3.py": "https://bbs.csdn.net/topics/603857824",
"data/books/1.Python编程无师自通/第14章 深入面向对象编程/14.1 类变量与实例变量/code_1.py": "https://bbs.csdn.net/topics/603857825",
"data/books/1.Python编程无师自通/第14章 深入面向对象编程/14.1 类变量与实例变量/code_2.py": "https://bbs.csdn.net/topics/603857696",
"data/books/1.Python编程无师自通/第14章 深入面向对象编程/14.1 类变量与实例变量/code_3.py": "https://bbs.csdn.net/topics/603857777",
"data/books/1.Python编程无师自通/第14章 深入面向对象编程/14.3 is/code_1.py": "https://bbs.csdn.net/topics/603857915",
"data/books/1.Python编程无师自通/第14章 深入面向对象编程/14.3 is/code_2.py": "https://bbs.csdn.net/topics/603857697",
"data/books/1.Python编程无师自通/第14章 深入面向对象编程/14.2 魔法方法/code_1.py": "https://bbs.csdn.net/topics/603857826",
"data/books/1.Python编程无师自通/第14章 深入面向对象编程/14.2 魔法方法/code_2.py": "https://bbs.csdn.net/topics/603857698",
"data/books/1.Python编程无师自通/第14章 深入面向对象编程/14.2 魔法方法/code_3.py": "https://bbs.csdn.net/topics/603857916",
"data/books/1.Python编程无师自通/第19章 版本控制/19.7 diff/code_4.py": "https://bbs.csdn.net/topics/603858002",
"data/books/1.Python编程无师自通/第19章 版本控制/19.7 diff/code_1.py": "https://bbs.csdn.net/topics/603857781",
"data/books/1.Python编程无师自通/第19章 版本控制/19.7 diff/code_5.py": "https://bbs.csdn.net/topics/603857784",
"data/books/1.Python编程无师自通/第19章 版本控制/19.7 diff/code_2.py": "https://bbs.csdn.net/topics/603857830",
"data/books/1.Python编程无师自通/第19章 版本控制/19.7 diff/code_3.py": "https://bbs.csdn.net/topics/603857919",
"data/books/1.Python编程无师自通/第19章 版本控制/19.2 入门/code_1.py": "https://bbs.csdn.net/topics/603857835",
"data/books/1.Python编程无师自通/第19章 版本控制/19.2 入门/code_2.py": "https://bbs.csdn.net/topics/603858012",
"data/books/1.Python编程无师自通/第19章 版本控制/19.2 入门/code_3.py": "https://bbs.csdn.net/topics/603857792",
"data/books/1.Python编程无师自通/第19章 版本控制/19.4 推送示例/code_4.py": "https://bbs.csdn.net/topics/603857793",
"data/books/1.Python编程无师自通/第19章 版本控制/19.4 推送示例/code_1.py": "https://bbs.csdn.net/topics/603857926",
"data/books/1.Python编程无师自通/第19章 版本控制/19.4 推送示例/code_5.py": "https://bbs.csdn.net/topics/603858013",
"data/books/1.Python编程无师自通/第19章 版本控制/19.4 推送示例/code_2.py": "https://bbs.csdn.net/topics/603858014",
"data/books/1.Python编程无师自通/第19章 版本控制/19.4 推送示例/code_6.py": "https://bbs.csdn.net/topics/603857836",
"data/books/1.Python编程无师自通/第19章 版本控制/19.4 推送示例/code_7.py": "https://bbs.csdn.net/topics/603857927",
"data/books/1.Python编程无师自通/第19章 版本控制/19.4 推送示例/code_3.py": "https://bbs.csdn.net/topics/603857794",
"data/books/1.Python编程无师自通/第19章 版本控制/19.4 推送示例/code_8.py": "https://bbs.csdn.net/topics/603857795",
"data/books/1.Python编程无师自通/第19章 版本控制/19.5 拉取示例/code_1.py": "https://bbs.csdn.net/topics/603857796",
"data/books/1.Python编程无师自通/第19章 版本控制/19.5 拉取示例/code_2.py": "https://bbs.csdn.net/topics/603857797",
"data/books/1.Python编程无师自通/第19章 版本控制/19.3 推送和拉取/code_1.py": "https://bbs.csdn.net/topics/603857928",
"data/books/1.Python编程无师自通/第19章 版本控制/19.6 回退版本/code_1.py": "https://bbs.csdn.net/topics/603857837",
"data/books/1.Python编程无师自通/第15章 综合练习/15.5 战争/code_1.py": "https://bbs.csdn.net/topics/603857929",
"data/books/1.Python编程无师自通/第15章 综合练习/15.3 玩家/code_1.py": "https://bbs.csdn.net/topics/603857838",
"data/books/1.Python编程无师自通/第15章 综合练习/15.4 游戏/code_1.py": "https://bbs.csdn.net/topics/603858015",
"data/books/1.Python编程无师自通/第15章 综合练习/15.2 牌堆/code_1.py": "https://bbs.csdn.net/topics/603857839",
"data/books/1.Python编程无师自通/第15章 综合练习/15.2 牌堆/code_2.py": "https://bbs.csdn.net/topics/603857840",
"data/books/1.Python编程无师自通/第15章 综合练习/15.1 卡牌/code_1.py": "https://bbs.csdn.net/topics/603857930",
"data/books/1.Python编程无师自通/第15章 综合练习/15.1 卡牌/code_2.py": "https://bbs.csdn.net/topics/603858016",
"data/books/1.Python编程无师自通/第15章 综合练习/15.1 卡牌/code_3.py": "https://bbs.csdn.net/topics/603858017",
"data/books/1.Python编程无师自通/第21章 数据结构/21.2 栈/code_4.py": "https://bbs.csdn.net/topics/603857931",
"data/books/1.Python编程无师自通/第21章 数据结构/21.2 栈/code_1.py": "https://bbs.csdn.net/topics/603857798",
"data/books/1.Python编程无师自通/第21章 数据结构/21.2 栈/code_5.py": "https://bbs.csdn.net/topics/603857932",
"data/books/1.Python编程无师自通/第21章 数据结构/21.2 栈/code_2.py": "https://bbs.csdn.net/topics/603857933",
"data/books/1.Python编程无师自通/第21章 数据结构/21.2 栈/code_3.py": "https://bbs.csdn.net/topics/603857934",
"data/books/1.Python编程无师自通/第21章 数据结构/21.5 购票队列/code_1.py": "https://bbs.csdn.net/topics/603857841",
"data/books/1.Python编程无师自通/第21章 数据结构/21.3 使用栈逆转字符串/code_1.py": "https://bbs.csdn.net/topics/603857842",
"data/books/1.Python编程无师自通/第21章 数据结构/21.4 队列/code_4.py": "https://bbs.csdn.net/topics/603858018",
"data/books/1.Python编程无师自通/第21章 数据结构/21.4 队列/code_1.py": "https://bbs.csdn.net/topics/603857935",
"data/books/1.Python编程无师自通/第21章 数据结构/21.4 队列/code_2.py": "https://bbs.csdn.net/topics/603858019",
"data/books/1.Python编程无师自通/第21章 数据结构/21.4 队列/code_3.py": "https://bbs.csdn.net/topics/603857799",
"data/books/1.Python编程无师自通/第02章 起步/2.1 什么是编程/code_1.py": "https://bbs.csdn.net/topics/603858100",
"data/books/1.Python编程无师自通/第02章 起步/2.1 什么是编程/code_2.py": "https://bbs.csdn.net/topics/603857843",
"data/books/1.Python编程无师自通/第05章 容器/5.4 字典/code_4.py": "https://bbs.csdn.net/topics/603857844",
"data/books/1.Python编程无师自通/第05章 容器/5.4 字典/code_1.py": "https://bbs.csdn.net/topics/603858101",
"data/books/1.Python编程无师自通/第05章 容器/5.4 字典/code_5.py": "https://bbs.csdn.net/topics/603857936",
"data/books/1.Python编程无师自通/第05章 容器/5.4 字典/code_2.py": "https://bbs.csdn.net/topics/603858020",
"data/books/1.Python编程无师自通/第05章 容器/5.4 字典/code_6.py": "https://bbs.csdn.net/topics/603858103",
"data/books/1.Python编程无师自通/第05章 容器/5.4 字典/code_7.py": "https://bbs.csdn.net/topics/603857937",
"data/books/1.Python编程无师自通/第05章 容器/5.4 字典/code_3.py": "https://bbs.csdn.net/topics/603857846",
"data/books/1.Python编程无师自通/第05章 容器/5.4 字典/code_8.py": "https://bbs.csdn.net/topics/603858021",
"data/books/1.Python编程无师自通/第05章 容器/5.2 列表/code_13.py": "https://bbs.csdn.net/topics/603857938",
"data/books/1.Python编程无师自通/第05章 容器/5.2 列表/code_4.py": "https://bbs.csdn.net/topics/603857848",
"data/books/1.Python编程无师自通/第05章 容器/5.2 列表/code_1.py": "https://bbs.csdn.net/topics/603857943",
"data/books/1.Python编程无师自通/第05章 容器/5.2 列表/code_12.py": "https://bbs.csdn.net/topics/603858027",
"data/books/1.Python编程无师自通/第05章 容器/5.2 列表/code_5.py": "https://bbs.csdn.net/topics/603857857",
"data/books/1.Python编程无师自通/第05章 容器/5.2 列表/code_15.py": "https://bbs.csdn.net/topics/603857951",
"data/books/1.Python编程无师自通/第05章 容器/5.2 列表/code_2.py": "https://bbs.csdn.net/topics/603858031",
"data/books/1.Python编程无师自通/第05章 容器/5.2 列表/code_11.py": "https://bbs.csdn.net/topics/603857858",
"data/books/1.Python编程无师自通/第05章 容器/5.2 列表/code_6.py": "https://bbs.csdn.net/topics/603857952",
"data/books/1.Python编程无师自通/第05章 容器/5.2 列表/code_10.py": "https://bbs.csdn.net/topics/603858112",
"data/books/1.Python编程无师自通/第05章 容器/5.2 列表/code_7.py": "https://bbs.csdn.net/topics/603857859",
"data/books/1.Python编程无师自通/第05章 容器/5.2 列表/code_14.py": "https://bbs.csdn.net/topics/603858113",
"data/books/1.Python编程无师自通/第05章 容器/5.2 列表/code_3.py": "https://bbs.csdn.net/topics/603857953",
"data/books/1.Python编程无师自通/第05章 容器/5.2 列表/code_8.py": "https://bbs.csdn.net/topics/603857860",
"data/books/1.Python编程无师自通/第05章 容器/5.2 列表/code_9.py": "https://bbs.csdn.net/topics/603857954",
"data/books/1.Python编程无师自通/第05章 容器/5.1 方法/code_1.py": "https://bbs.csdn.net/topics/603857955",
"data/books/1.Python编程无师自通/第05章 容器/5.5 容器嵌套容器/code_4.py": "https://bbs.csdn.net/topics/603858032",
"data/books/1.Python编程无师自通/第05章 容器/5.5 容器嵌套容器/code_1.py": "https://bbs.csdn.net/topics/603858033",
"data/books/1.Python编程无师自通/第05章 容器/5.5 容器嵌套容器/code_5.py": "https://bbs.csdn.net/topics/603857956",
"data/books/1.Python编程无师自通/第05章 容器/5.5 容器嵌套容器/code_2.py": "https://bbs.csdn.net/topics/603858034",
"data/books/1.Python编程无师自通/第05章 容器/5.5 容器嵌套容器/code_3.py": "https://bbs.csdn.net/topics/603857861",
"data/books/1.Python编程无师自通/第05章 容器/5.3 元组/code_4.py": "https://bbs.csdn.net/topics/603858035",
"data/books/1.Python编程无师自通/第05章 容器/5.3 元组/code_1.py": "https://bbs.csdn.net/topics/603858114",
"data/books/1.Python编程无师自通/第05章 容器/5.3 元组/code_5.py": "https://bbs.csdn.net/topics/603858036",
"data/books/1.Python编程无师自通/第05章 容器/5.3 元组/code_2.py": "https://bbs.csdn.net/topics/603858037",
"data/books/1.Python编程无师自通/第05章 容器/5.3 元组/code_6.py": "https://bbs.csdn.net/topics/603857862",
"data/books/1.Python编程无师自通/第05章 容器/5.3 元组/code_7.py": "https://bbs.csdn.net/topics/603857957",
"data/books/1.Python编程无师自通/第05章 容器/5.3 元组/code_3.py": "https://bbs.csdn.net/topics/603858115",
"data/books/1.Python编程无师自通/第05章 容器/5.3 元组/code_8.py": "https://bbs.csdn.net/topics/603857958",
"data/books/1.Python编程无师自通/第13章 面向对象编程的四大支柱/13.4 继承/code_4.py": "https://bbs.csdn.net/topics/603857863",
"data/books/1.Python编程无师自通/第13章 面向对象编程的四大支柱/13.4 继承/code_1.py": "https://bbs.csdn.net/topics/603857959",
"data/books/1.Python编程无师自通/第13章 面向对象编程的四大支柱/13.4 继承/code_2.py": "https://bbs.csdn.net/topics/603858038",
"data/books/1.Python编程无师自通/第13章 面向对象编程的四大支柱/13.4 继承/code_3.py": "https://bbs.csdn.net/topics/603858116",
"data/books/1.Python编程无师自通/第13章 面向对象编程的四大支柱/13.1 封装/code_4.py": "https://bbs.csdn.net/topics/603858039",
"data/books/1.Python编程无师自通/第13章 面向对象编程的四大支柱/13.1 封装/code_1.py": "https://bbs.csdn.net/topics/603858040",
"data/books/1.Python编程无师自通/第13章 面向对象编程的四大支柱/13.1 封装/code_2.py": "https://bbs.csdn.net/topics/603858117",
"data/books/1.Python编程无师自通/第13章 面向对象编程的四大支柱/13.1 封装/code_3.py": "https://bbs.csdn.net/topics/603857960",
"data/books/1.Python编程无师自通/第13章 面向对象编程的四大支柱/13.5 组合/code_1.py": "https://bbs.csdn.net/topics/603858041",
"data/books/1.Python编程无师自通/第13章 面向对象编程的四大支柱/13.5 组合/code_2.py": "https://bbs.csdn.net/topics/603858118",
"data/books/1.Python编程无师自通/第13章 面向对象编程的四大支柱/13.3 多态/code_1.py": "https://bbs.csdn.net/topics/603857864",
"data/books/1.Python编程无师自通/第13章 面向对象编程的四大支柱/13.3 多态/code_2.py": "https://bbs.csdn.net/topics/603857865",
"data/books/1.Python编程无师自通/第13章 面向对象编程的四大支柱/13.3 多态/code_3.py": "https://bbs.csdn.net/topics/603857961",
"data/books/1.Python编程无师自通/第07章 循环/7.4 break语句/code_1.py": "https://bbs.csdn.net/topics/603858042",
"data/books/1.Python编程无师自通/第07章 循环/7.4 break语句/code_2.py": "https://bbs.csdn.net/topics/603857866",
"data/books/1.Python编程无师自通/第07章 循环/7.4 break语句/code_3.py": "https://bbs.csdn.net/topics/603857962",
"data/books/1.Python编程无师自通/第07章 循环/7.3 while循环/code_1.py": "https://bbs.csdn.net/topics/603857867",
"data/books/1.Python编程无师自通/第07章 循环/7.3 while循环/code_2.py": "https://bbs.csdn.net/topics/603857868",
"data/books/1.Python编程无师自通/第07章 循环/7.6 嵌套循环/code_1.py": "https://bbs.csdn.net/topics/603858119",
"data/books/1.Python编程无师自通/第07章 循环/7.6 嵌套循环/code_2.py": "https://bbs.csdn.net/topics/603858043",
"data/books/1.Python编程无师自通/第07章 循环/7.6 嵌套循环/code_3.py": "https://bbs.csdn.net/topics/603857869",
"data/books/1.Python编程无师自通/第07章 循环/7.2 range函数/code_1.py": "https://bbs.csdn.net/topics/603858044",
"data/books/1.Python编程无师自通/第07章 循环/7.1 for循环/code_4.py": "https://bbs.csdn.net/topics/603858120",
"data/books/1.Python编程无师自通/第07章 循环/7.1 for循环/code_1.py": "https://bbs.csdn.net/topics/603858121",
"data/books/1.Python编程无师自通/第07章 循环/7.1 for循环/code_5.py": "https://bbs.csdn.net/topics/603857963",
"data/books/1.Python编程无师自通/第07章 循环/7.1 for循环/code_2.py": "https://bbs.csdn.net/topics/603857870",
"data/books/1.Python编程无师自通/第07章 循环/7.1 for循环/code_6.py": "https://bbs.csdn.net/topics/603858045",
"data/books/1.Python编程无师自通/第07章 循环/7.1 for循环/code_7.py": "https://bbs.csdn.net/topics/603858122",
"data/books/1.Python编程无师自通/第07章 循环/7.1 for循环/code_3.py": "https://bbs.csdn.net/topics/603858123",
"data/books/1.Python编程无师自通/第07章 循环/7.5 continue语句/code_1.py": "https://bbs.csdn.net/topics/603857871",
"data/books/1.Python编程无师自通/第07章 循环/7.5 continue语句/code_2.py": "https://bbs.csdn.net/topics/603857872",
"data/books/1.Python编程无师自通/第16章 Bash/16.11 用户/code_1.py": "https://bbs.csdn.net/topics/603858124",
"data/books/1.Python编程无师自通/第16章 Bash/16.11 用户/code_2.py": "https://bbs.csdn.net/topics/603857873",
"data/books/1.Python编程无师自通/第16章 Bash/16.7 旗标/code_1.py": "https://bbs.csdn.net/topics/603857874",
"data/books/1.Python编程无师自通/第16章 Bash/16.7 旗标/code_2.py": "https://bbs.csdn.net/topics/603858125",
"data/books/1.Python编程无师自通/第16章 Bash/16.9 管道/code_1.py": "https://bbs.csdn.net/topics/603857964",
"data/books/1.Python编程无师自通/第16章 Bash/16.6 导航/code_4.py": "https://bbs.csdn.net/topics/603858126",
"data/books/1.Python编程无师自通/第16章 Bash/16.6 导航/code_1.py": "https://bbs.csdn.net/topics/603857965",
"data/books/1.Python编程无师自通/第16章 Bash/16.6 导航/code_5.py": "https://bbs.csdn.net/topics/603858046",
"data/books/1.Python编程无师自通/第16章 Bash/16.6 导航/code_2.py": "https://bbs.csdn.net/topics/603857875",
"data/books/1.Python编程无师自通/第16章 Bash/16.6 导航/code_6.py": "https://bbs.csdn.net/topics/603857876",
"data/books/1.Python编程无师自通/第16章 Bash/16.6 导航/code_7.py": "https://bbs.csdn.net/topics/603858127",
"data/books/1.Python编程无师自通/第16章 Bash/16.6 导航/code_3.py": "https://bbs.csdn.net/topics/603857877",
"data/books/1.Python编程无师自通/第16章 Bash/16.6 导航/code_8.py": "https://bbs.csdn.net/topics/603857966",
"data/books/1.Python编程无师自通/第16章 Bash/16.6 导航/code_9.py": "https://bbs.csdn.net/topics/603858047",
"data/books/1.Python编程无师自通/第16章 Bash/16.8 隐藏文件/code_1.py": "https://bbs.csdn.net/topics/603857967",
"data/books/1.Python编程无师自通/第16章 Bash/16.10 环境变量/code_1.py": "https://bbs.csdn.net/topics/603858048",
"data/books/1.Python编程无师自通/第16章 Bash/16.10 环境变量/code_2.py": "https://bbs.csdn.net/topics/603858128",
"data/books/1.Python编程无师自通/第16章 Bash/16.3 命令/code_1.py": "https://bbs.csdn.net/topics/603858129",
"data/books/1.Python编程无师自通/第16章 Bash/16.3 命令/code_2.py": "https://bbs.csdn.net/topics/603857968",
"data/books/1.Python编程无师自通/第16章 Bash/16.3 命令/code_3.py": "https://bbs.csdn.net/topics/603857878",
"data/books/1.Python编程无师自通/第16章 Bash/16.4 最近命令/code_1.py": "https://bbs.csdn.net/topics/603857969",
"data/books/1.Python编程无师自通/第16章 Bash/16.5 相对路径与绝对路径/code_1.py": "https://bbs.csdn.net/topics/603858049",
"data/books/1.Python编程无师自通/第17章 正则表达式/17.5 匹配数字/code_1.py": "https://bbs.csdn.net/topics/603857970",
"data/books/1.Python编程无师自通/第17章 正则表达式/17.5 匹配数字/code_2.py": "https://bbs.csdn.net/topics/603857971",
"data/books/1.Python编程无师自通/第17章 正则表达式/17.1 初始配置/code_1.py": "https://bbs.csdn.net/topics/603857879",
"data/books/1.Python编程无师自通/第17章 正则表达式/17.2 简单匹配/code_4.py": "https://bbs.csdn.net/topics/603857972",
"data/books/1.Python编程无师自通/第17章 正则表达式/17.2 简单匹配/code_1.py": "https://bbs.csdn.net/topics/603857880",
"data/books/1.Python编程无师自通/第17章 正则表达式/17.2 简单匹配/code_5.py": "https://bbs.csdn.net/topics/603858050",
"data/books/1.Python编程无师自通/第17章 正则表达式/17.2 简单匹配/code_2.py": "https://bbs.csdn.net/topics/603858130",
"data/books/1.Python编程无师自通/第17章 正则表达式/17.2 简单匹配/code_6.py": "https://bbs.csdn.net/topics/603858051",
"data/books/1.Python编程无师自通/第17章 正则表达式/17.2 简单匹配/code_3.py": "https://bbs.csdn.net/topics/603858052",
"data/books/1.Python编程无师自通/第17章 正则表达式/17.6 重复/code_4.py": "https://bbs.csdn.net/topics/603858131",
"data/books/1.Python编程无师自通/第17章 正则表达式/17.6 重复/code_1.py": "https://bbs.csdn.net/topics/603857881",
"data/books/1.Python编程无师自通/第17章 正则表达式/17.6 重复/code_5.py": "https://bbs.csdn.net/topics/603858053",
"data/books/1.Python编程无师自通/第17章 正则表达式/17.6 重复/code_2.py": "https://bbs.csdn.net/topics/603857882",
"data/books/1.Python编程无师自通/第17章 正则表达式/17.6 重复/code_3.py": "https://bbs.csdn.net/topics/603857973",
"data/books/1.Python编程无师自通/第17章 正则表达式/17.3 匹配起始位置/code_1.py": "https://bbs.csdn.net/topics/603858132",
"data/books/1.Python编程无师自通/第17章 正则表达式/17.3 匹配起始位置/code_2.py": "https://bbs.csdn.net/topics/603858133",
"data/books/1.Python编程无师自通/第17章 正则表达式/17.3 匹配起始位置/code_3.py": "https://bbs.csdn.net/topics/603857883",
"data/books/1.Python编程无师自通/第17章 正则表达式/17.7 转义/code_1.py": "https://bbs.csdn.net/topics/603857884",
"data/books/1.Python编程无师自通/第17章 正则表达式/17.7 转义/code_2.py": "https://bbs.csdn.net/topics/603857885",
"data/books/1.Python编程无师自通/第17章 正则表达式/17.4 匹配多个字符/code_1.py": "https://bbs.csdn.net/topics/603857886",
"data/books/1.Python编程无师自通/第17章 正则表达式/17.4 匹配多个字符/code_2.py": "https://bbs.csdn.net/topics/603857974",
"data/books/1.Python编程无师自通/第04章 函数/4.10 有需要才使用变量/code_1.py": "https://bbs.csdn.net/topics/603857975",
"data/books/1.Python编程无师自通/第04章 函数/4.10 有需要才使用变量/code_2.py": "https://bbs.csdn.net/topics/603857976",
"data/books/1.Python编程无师自通/第04章 函数/4.9 文档字符串/code_1.py": "https://bbs.csdn.net/topics/603858134",
"data/books/1.Python编程无师自通/第04章 函数/4.4 内置函数/code_4.py": "https://bbs.csdn.net/topics/603857887",
"data/books/1.Python编程无师自通/第04章 函数/4.4 内置函数/code_1.py": "https://bbs.csdn.net/topics/603857977",
"data/books/1.Python编程无师自通/第04章 函数/4.4 内置函数/code_5.py": "https://bbs.csdn.net/topics/603858135",
"data/books/1.Python编程无师自通/第04章 函数/4.4 内置函数/code_2.py": "https://bbs.csdn.net/topics/603858054",
"data/books/1.Python编程无师自通/第04章 函数/4.4 内置函数/code_6.py": "https://bbs.csdn.net/topics/603858055",
"data/books/1.Python编程无师自通/第04章 函数/4.4 内置函数/code_7.py": "https://bbs.csdn.net/topics/603858136",
"data/books/1.Python编程无师自通/第04章 函数/4.4 内置函数/code_3.py": "https://bbs.csdn.net/topics/603857978",
"data/books/1.Python编程无师自通/第04章 函数/4.3 定义函数/code_4.py": "https://bbs.csdn.net/topics/603857888",
"data/books/1.Python编程无师自通/第04章 函数/4.3 定义函数/code_1.py": "https://bbs.csdn.net/topics/603857889",
"data/books/1.Python编程无师自通/第04章 函数/4.3 定义函数/code_5.py": "https://bbs.csdn.net/topics/603858056",
"data/books/1.Python编程无师自通/第04章 函数/4.3 定义函数/code_2.py": "https://bbs.csdn.net/topics/603858137",
"data/books/1.Python编程无师自通/第04章 函数/4.3 定义函数/code_6.py": "https://bbs.csdn.net/topics/603858057",
"data/books/1.Python编程无师自通/第04章 函数/4.3 定义函数/code_7.py": "https://bbs.csdn.net/topics/603858138",
"data/books/1.Python编程无师自通/第04章 函数/4.3 定义函数/code_3.py": "https://bbs.csdn.net/topics/603858139",
"data/books/1.Python编程无师自通/第04章 函数/4.3 定义函数/code_8.py": "https://bbs.csdn.net/topics/603857890",
"data/books/1.Python编程无师自通/第04章 函数/4.7 作用域/code_4.py": "https://bbs.csdn.net/topics/603858140",
"data/books/1.Python编程无师自通/第04章 函数/4.7 作用域/code_1.py": "https://bbs.csdn.net/topics/603857979",
"data/books/1.Python编程无师自通/第04章 函数/4.7 作用域/code_5.py": "https://bbs.csdn.net/topics/603857980",
"data/books/1.Python编程无师自通/第04章 函数/4.7 作用域/code_2.py": "https://bbs.csdn.net/topics/603857981",
"data/books/1.Python编程无师自通/第04章 函数/4.7 作用域/code_6.py": "https://bbs.csdn.net/topics/603857982",
"data/books/1.Python编程无师自通/第04章 函数/4.7 作用域/code_3.py": "https://bbs.csdn.net/topics/603857891",
"data/books/1.Python编程无师自通/第04章 函数/4.2 函数/code_1.py": "https://bbs.csdn.net/topics/603858141",
"data/books/1.Python编程无师自通/第04章 函数/4.5 复用函数/code_1.py": "https://bbs.csdn.net/topics/603858058",
"data/books/1.Python编程无师自通/第04章 函数/4.5 复用函数/code_2.py": "https://bbs.csdn.net/topics/603858059",
"data/books/1.Python编程无师自通/第04章 函数/4.5 复用函数/code_3.py": "https://bbs.csdn.net/topics/603858060",
"data/books/1.Python编程无师自通/第04章 函数/4.8 异常处理/code_4.py": "https://bbs.csdn.net/topics/603858142",
"data/books/1.Python编程无师自通/第04章 函数/4.8 异常处理/code_1.py": "https://bbs.csdn.net/topics/603857892",
"data/books/1.Python编程无师自通/第04章 函数/4.8 异常处理/code_5.py": "https://bbs.csdn.net/topics/603858143",
"data/books/1.Python编程无师自通/第04章 函数/4.8 异常处理/code_2.py": "https://bbs.csdn.net/topics/603857893",
"data/books/1.Python编程无师自通/第04章 函数/4.8 异常处理/code_6.py": "https://bbs.csdn.net/topics/603858061",
"data/books/1.Python编程无师自通/第04章 函数/4.8 异常处理/code_3.py": "https://bbs.csdn.net/topics/603858144",
"data/books/1.Python编程无师自通/第04章 函数/4.6 必选及可选参数/code_1.py": "https://bbs.csdn.net/topics/603858145",
"data/books/1.Python编程无师自通/第04章 函数/4.6 必选及可选参数/code_2.py": "https://bbs.csdn.net/topics/603857983"
}
\ No newline at end of file
from src.ebook.extract_book_code import extract_code
if __name__ == "__main__":
extract_code()
import json
import requests
import logging
logger = logging.getLogger(__name__)
def get_chapter_content(params):
url = 'http://192.168.50.117:9003/v1/chapter/content'
headers = {
"Cookie":"UserToken=149ba8a7a8d341bbbe41f904c4c9b176;UserName=xiuxiuyayayy"
}
result = requests.get(url=url, params=params, headers=headers)
if result.status_code == 200:
ret = json.loads(result.text)
logger.info('request success')
content = ret['data']
return content
else:
logger.info('request failed!!!!!')
return {}
def get_chapter_list(params):
url = 'http://192.168.50.117:9003/inner/v1/chapter/list'
headers = {
"Cookie":"UserToken=149ba8a7a8d341bbbe41f904c4c9b176;UserName=xiuxiuyayayy"
}
result = requests.get(url=url, params=params, headers=headers)
if result.status_code == 200:
ret = json.loads(result.text)
logger.info('request success')
content = ret['data']
return content
else:
logger.info('request failed!!!!!')
return {}
\ No newline at end of file
import json
import os
import re
import html
from bs4 import BeautifulSoup
from .get_book_chapter_id_list import get_chapter_id_list
from .ebook_get_request import get_chapter_content
def extract_code():
book_mapping_path = "data/book_mapping.json"
with open(book_mapping_path, "r") as f:
book_mapping = json.load(f)
for book_idx, book_name in enumerate(book_mapping.keys()):
if book_name == 'Python编程无师自通':
continue
book_dir_name = '{}.{}'.format(book_idx + 1, book_name)
book_dir = os.path.join('data/books', book_dir_name)
if not os.path.exists(book_dir):
os.mkdir(book_dir)
print(book_dir_name)
book_id = book_mapping[book_name]
request_get_chapter_id_list_params = {"bookId": book_id, "is_main": 1}
chapter_id_list = get_chapter_id_list(
request_get_chapter_id_list_params)
print(chapter_id_list)
for chapter_id in chapter_id_list:
request_get_chapter_content_params = {
'bookId': book_id,
'chapterId': chapter_id
}
chapter_resp = get_chapter_content(
request_get_chapter_content_params)
chapter_name = chapter_resp['name']
chapter_content = chapter_resp['content']
try:
if book_name == "零基础学机器学习":
chapter_num = re.findall(r'第(.*)课', chapter_name)[0]
chapter_name_modify = re.sub(
r'第(.*)课', r'第{}课'.format(chapter_num.zfill(2)),
chapter_name)
else:
chapter_num = re.findall(r'第(.*)章', chapter_name)[0]
chapter_name_modify = re.sub(
r'第(.*)章', r'第{}章'.format(chapter_num.zfill(2)),
chapter_name)
chapter_name = chapter_name_modify
except:
# print('该章节没有章节序号: {}'.format(chapter_name))
pass
chapter_dir = os.path.join(book_dir, chapter_name)
if not os.path.exists(chapter_dir):
os.mkdir(chapter_dir)
# print('创建文件夹: {}'.format(chapter_dir))
chapter_content = html.unescape(chapter_content)
if book_name == "全程软件测试(第3版)":
section_list = re.findall(r'<h2.*>(.*?)</h2>', chapter_content)
section_content_list = re.split(r'<h2.*?>.*?</h2>',
chapter_content,
flags=re.S)
section_dir_list = []
for section in section_list:
section = section.replace(' ', ' ')
if section.find(r'/') != -1:
section = section.replace('/', '')
section_dir = os.path.join(chapter_dir, section)
print(section_dir)
if not os.path.exists(section_dir):
os.mkdir(section_dir)
section_dir_list.append(section_dir)
for idx, section_content in enumerate(section_content_list):
if idx == 0:
save_dir = os.path.join(chapter_dir, 'text.html')
else:
save_dir = os.path.join(section_dir_list[idx - 1],
'text.html')
code_list = re.findall(r'<code>(.*?)</code>',
section_content, re.S)
res_code_list = []
count = 0
for i in code_list:
if len(i.split('\n')) < 2:
continue
count += 1
i = html.unescape(i)
soup = BeautifulSoup(i)
res_str = soup.get_text()
if idx == 0:
code_save_dir = os.path.join(
chapter_dir, 'code_0.java')
else:
code_save_dir = os.path.join(
section_dir_list[idx - 1],
'code_{}.java'.format(count))
print(res_str)
with open(code_save_dir, 'w', encoding='utf-8') as f:
f.write(res_str)
# clean_text_list = []
# for line in res_str.split('\n'):
# if line == '':
# continue
# if line[0].isdigit():
# line = re.findall(r'^[0-9]+ {0,2}(.*)',
# line)[0]
# # print(line)
# else:
# if line.startswith('>>'):
# break
# clean_text_list.append(line)
# clean_code = '\n'.join(clean_text_list)
# print(clean_code)
\ No newline at end of file
import json
import re
import html
import nltk
import html2text
import os
import pandas as pd
from bs4 import BeautifulSoup
from .ebook_get_request import get_chapter_list
def get_chapter_id_list(param):
chapter_list = []
ret = get_chapter_list(param)
for item in ret:
chapterid = item['chapterid']
chapter_list.append(chapterid)
return chapter_list
import json
import re
import html
import nltk
import html2text
import os
import pandas as pd
from bs4 import BeautifulSoup
from src.extract.get_book_content import get_chapter_content
def extract_structure():
params = {
"bookId": "c798a5992a654857867ec15660e1c32a",
}
book_path = '20211203Python编程无师自通.csv'
book_data = pd.read_csv(book_path)
chapterid_list = book_data['chapterid']
for chapter_id in chapterid_list:
# chapter_id = 87
params['chapterId'] = chapter_id
res = get_chapter_content(params)
chapter_name = res['name']
chapter_dir = './test_dir/{}'.format(chapter_name)
try:
chapter_num = re.findall(r'第(.*)章', chapter_dir)[0]
print(chapter_num.zfill(2))
chapter_dir = re.sub(r'第(.*)章', r'第{}章'.format(chapter_num.zfill(2)), chapter_dir)
print(chapter_dir)
except:
continue
if not os.path.exists(chapter_dir):
os.mkdir(chapter_dir)
content = res['content']
content = html.unescape(content)
section_list = re.findall(r'<h2.*>(.*?)</h2>', content)
section_content_list = re.split(r'<h2.*?>.*?</h2>', content, flags=re.S)
section_dir_list = []
for section in section_list:
section_dir = os.path.join(chapter_dir, section)
if not os.path.exists(section_dir):
os.mkdir(section_dir)
section_dir_list.append(section_dir)
# print(section_dir_list)
for idx, section_content in enumerate(section_content_list):
if idx == 0:
save_dir = os.path.join(chapter_dir, 'text.html')
else:
save_dir = os.path.join(section_dir_list[idx-1], 'text.html')
# with open(save_dir, 'w', encoding='utf-8') as f:
# f.write(section_content)
code_list = re.findall(r'<code>(.*?)</code>', section_content, re.S)
res_code_list = []
count = 0
for i in code_list:
if len(i.split('\n')) < 2:
continue
count+=1
i = html.unescape(i)
soup = BeautifulSoup(i)
res_str = soup.get_text()
if idx == 0:
code_save_dir = os.path.join(chapter_dir, 'code_0.py')
else:
code_save_dir = os.path.join(section_dir_list[idx-1], 'code_{}.py'.format(count))
clean_text_list = []
for line in res_str.split('\n'):
if line == '':
continue
if line[0].isdigit():
line = re.findall(r'^[0-9]+ {0,2}(.*)', line)[0]
# print(line)
else:
if line.startswith('>>'):
break
clean_text_list.append(line)
clean_code = '\n'.join(clean_text_list)
with open(code_save_dir, 'w', encoding='utf-8') as f:
f.write(clean_code)
import json
import requests
import logging
logger = logging.getLogger(__name__)
def get_chapter_content(params):
url = 'http://192.168.50.117:9003/v1/chapter/content'
headers = {
"Cookie":"UserToken=149ba8a7a8d341bbbe41f904c4c9b176;UserName=xiuxiuyayayy"
}
result = requests.get(url=url, params=params, headers=headers)
if result.status_code == 200:
ret = json.loads(result.text)
logger.info('request success')
content = ret['data']
return content
else:
logger.info('request failed!!!!!')
return {}
\ No newline at end of file
# -*- coding: utf-8 -*-
import logging
from genericpath import exists
import json
import os
import uuid
import sys
import re
id_set = set()
logger = logging.getLogger(__name__)
logger.setLevel(logging.INFO)
handler = logging.StreamHandler(sys.stdout)
formatter = logging.Formatter('%(asctime)s - %(levelname)s - %(message)s')
handler.setFormatter(formatter)
logger.addHandler(handler)
def load_json(p):
with open(p, 'r', encoding='utf-8') as f:
return json.loads(f.read())
def dump_json(p, j, exist_ok=False, override=False):
if os.path.exists(p):
if exist_ok:
if not override:
return
else:
logger.error(f"{p} already exist")
sys.exit(0)
with open(p, 'w+', encoding='utf-8') as f:
f.write(json.dumps(j, indent=2, ensure_ascii=False))
def ensure_config(path):
config_path = os.path.join(path, "config.json")
if not os.path.exists(config_path):
node = {"keywords": []}
dump_json(config_path, node, exist_ok=True, override=False)
return node
else:
return load_json(config_path)
def parse_no_name(d):
p = r'(\d+)\.(.*)'
m = re.search(p, d)
try:
no = int(m.group(1))
dir_name = m.group(2)
except:
sys.exit(0)
return no, dir_name
def check_export(base, cfg):
flag = False
exports = []
for export in cfg.get('export', []):
ecfg_path = os.path.join(base, export)
if os.path.exists(ecfg_path):
exports.append(export)
else:
flag = True
if flag:
cfg["export"] = exports
return flag
class TreeWalker:
def __init__(self, root, tree_name, title=None, log=None):
self.name = tree_name
self.root = root
self.title = tree_name if title is None else title
self.tree = {}
self.logger = logger if log is None else log
def walk(self):
root = self.load_root()
root_node = {
"node_id": root["node_id"],
"keywords": root["keywords"],
"children": []
}
self.tree[root["tree_name"]] = root_node
self.load_levels(root_node)
self.load_chapters(self.root, root_node)
for index, level in enumerate(root_node["children"]):
level_title = list(level.keys())[0]
level_node = list(level.values())[0]
level_path = os.path.join(self.root, f"{index+1}.{level_title}")
self.load_chapters(level_path, level_node)
for index, chapter in enumerate(level_node["children"]):
chapter_title = list(chapter.keys())[0]
chapter_node = list(chapter.values())[0]
chapter_path = os.path.join(
level_path, f"{index+1}.{chapter_title}")
self.load_sections(chapter_path, chapter_node)
for index, section_node in enumerate(chapter_node["children"]):
section_title = list(section_node.keys())[0]
full_path = os.path.join(
chapter_path, f"{index}.{section_title}")
if os.path.isdir(full_path):
self.ensure_exercises(full_path)
tree_path = os.path.join(self.root, "tree.json")
dump_json(tree_path, self.tree, exist_ok=True, override=True)
return self.tree
def load_levels(self, root_node):
levels = []
for level in os.listdir(self.root):
if not os.path.isdir(level):
continue
level_path = os.path.join(self.root, level)
num, config = self.load_level_node(level_path)
levels.append((num, config))
levels = self.resort_children(self.root, levels)
root_node["children"] = [item[1] for item in levels]
return root_node
def load_level_node(self, level_path):
config = self.ensure_level_config(level_path)
num, name = self.extract_node_env(level_path)
result = {
name: {
"node_id": config["node_id"],
"keywords": config["keywords"],
"children": [],
}
}
return num, result
def load_chapters(self, base, level_node):
chapters = []
for name in os.listdir(base):
full_name = os.path.join(base, name)
if os.path.isdir(full_name):
num, chapter = self.load_chapter_node(full_name)
chapters.append((num, chapter))
chapters = self.resort_children(base, chapters)
level_node["children"] = [item[1] for item in chapters]
return level_node
def load_sections(self, base, chapter_node):
sections = []
for name in os.listdir(base):
full_name = os.path.join(base, name)
if os.path.isdir(full_name):
num, section = self.load_section_node(full_name)
sections.append((num, section))
sections = self.resort_children(base, sections)
chapter_node["children"] = [item[1] for item in sections]
return chapter_node
def resort_children(self, base, children):
children.sort(key=lambda item: item[0])
for index, [number, element] in enumerate(children):
title = list(element.keys())[0]
origin = os.path.join(base, f"{number}.{title}")
posted = os.path.join(base, f"{index+1}.{title}")
if origin != posted:
self.logger.info(f"rename [{origin}] to [{posted}]")
os.rename(origin, posted)
return children
def ensure_chapters(self):
for subdir in os.listdir(self.root):
self.ensure_level_config(subdir)
def load_root(self):
config_path = os.path.join(self.root, "config.json")
if not os.path.exists(config_path):
config = {
"tree_name": self.name,
"keywords": [],
"node_id": self.gen_node_id(),
}
dump_json(config_path, config, exist_ok=True, override=True)
else:
config = load_json(config_path)
flag, result = self.ensure_node_id(config)
if flag:
dump_json(config_path, result, exist_ok=True, override=True)
return config
def ensure_level_config(self, path):
config_path = os.path.join(path, "config.json")
if not os.path.exists(config_path):
config = {
"node_id": self.gen_node_id()
}
dump_json(config_path, config, exist_ok=True, override=True)
else:
config = load_json(config_path)
flag, result = self.ensure_node_id(config)
if flag:
dump_json(config_path, config, exist_ok=True, override=True)
return config
def ensure_chapter_config(self, path):
config_path = os.path.join(path, "config.json")
if not os.path.exists(config_path):
config = {
"node_id": self.gen_node_id(),
"keywords": []
}
dump_json(config_path, config, exist_ok=True, override=True)
else:
config = load_json(config_path)
flag, result = self.ensure_node_id(config)
if flag:
dump_json(config_path, config, exist_ok=True, override=True)
return config
def ensure_section_config(self, path):
config_path = os.path.join(path, "config.json")
if not os.path.exists(config_path):
config = {
"node_id": self.gen_node_id(),
"keywords": [],
"children": [],
"export": []
}
dump_json(config_path, config, exist_ok=True, override=True)
else:
config = load_json(config_path)
flag, result = self.ensure_node_id(config)
if flag:
dump_json(config_path, config, exist_ok=True, override=True)
return config
def ensure_node_id(self, config):
if "node_id" not in config:
config["node_id"] = self.gen_node_id()
return True, config
else:
return False, config
def gen_node_id(self):
return f"{self.name}-{uuid.uuid4().hex}"
def extract_node_env(self, path):
try:
_, dir = os.path.split(path)
self.logger.info(path)
number, title = dir.split(".", 1)
return int(number), title
except Exception as error:
self.logger.error(f"目录 [{path}] 解析失败,结构不合法,可能是缺少序号")
sys.exit(1)
def load_chapter_node(self, full_name):
config = self.ensure_chapter_config(full_name)
num, name = self.extract_node_env(full_name)
result = {
name: {
"node_id": config["node_id"],
"keywords": config["keywords"],
"children": [],
}
}
return num, result
def load_section_node(self, full_name):
config = self.ensure_section_config(full_name)
num, name = self.extract_node_env(full_name)
result = {
name: {
"node_id": config["node_id"],
"keywords": config["keywords"],
"children": config.get("children", [])
}
}
# if "children" in config:
# result["children"] = config["children"]
return num, result
def ensure_exercises(self, section_path):
config = self.ensure_section_config(section_path)
for e in config.get("export", []):
full_name = os.path.join(section_path, e)
exercise = load_json(full_name)
if "exercise_id" not in exercise:
exercise["exercise_id"] = uuid.uuid4().hex
dump_json(full_name, exercise)
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册