-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
timeface
authored and
timeface
committed
Oct 30, 2018
1 parent
36ea73b
commit 2049ff5
Showing
548 changed files
with
1,568 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
__pycache__/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"python.pythonPath": "/usr/local/bin/python3", | ||
"python.jediEnabled": false | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
<view> | ||
<text>{{block.text}}</text> | ||
<img src={{block.src}} /> | ||
|
||
<text>{{block.text}}</text> | ||
<img src={{block.src}} /> | ||
|
||
<text>{{block.text}}</text> | ||
<img src={{block.src}} /> | ||
</view> | ||
|
||
|
||
var formData = new formData(); | ||
forData.add('title', 'xxx'); | ||
formData.add('datetime'); | ||
formdata.add('authoer'); | ||
|
||
formData.add('img_1', Image); | ||
formData.add('text_1', String); | ||
|
||
|
||
/* | ||
如果在修改的模式下: | ||
1. 替换了图片/文字 | ||
2. 新增了图片/文字 | ||
3. 调整了{图片&文字}的顺序 | ||
|
||
*/ | ||
问题就成了: | ||
1. 如何 创建一个新的pageStructure | ||
2. 如何对一个已经存在的pageStructure对象,施加操作,使其变成另外一个对对象。并diff两者的差异 | ||
pageStructure = { | ||
title: 'title' | ||
time: time, | ||
author: 'author' | ||
|
||
content: [ | ||
{ | ||
id: id, | ||
image: url | path | "" , | ||
text: string | "" | ||
} | ||
] | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
## __metaclass__ = type ## when you use python2 | ||
|
||
class Person: | ||
## class body can include any statements and expression | ||
|
||
##foo.age is ok static attr | ||
##foo.__age is ok static attr | ||
##foo._Person__age is ok | ||
__age = 25 ## static attribute | ||
age = 0 ## static attribute | ||
def set_name(self, name): | ||
## outside foo.__name is not ok | ||
## outside foo._Person__name is ok | ||
self.__name = name | ||
def get_name(self): | ||
return self.__name | ||
def greet(self): | ||
print("Hello, world! I'm {}".format(self.name)) | ||
def __howOld(self): | ||
print("I'm {} years old".format(self.__age)) | ||
|
||
foo = Person() ##不需要new 关键字 | ||
bar = Person() | ||
foo.set_name('foo_foo') | ||
bar.set_name('bar_bar') | ||
foo.greet() | ||
## 可以通过 foo.name 取值;可以通过foo.name = 'other'赋值 !!!! | ||
##同一个模块再次import后, 会再次运行该模块吗 | ||
|
||
##类的静态属性,可以为所有的实例所读共享, 一旦某个实例去修改类的静态属性,那么该属性就会被复制到该实例的属性中 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
|
||
|
||
class SomeCustomException(Exception): | ||
pass | ||
|
||
class FristException: | ||
def learn(self): | ||
try: | ||
x = int( input("Enter first number") ) | ||
y = int( input("Enter second number") ) | ||
print( x/y ) | ||
except ZeroDivisionError: | ||
print("The second number can't be zero") | ||
|
||
|
||
class MuffledCalculator: | ||
muffled = False | ||
def cal(self, expr): | ||
try: | ||
return eval(expr) | ||
except ZeroDivisionError: | ||
if self.muffled: | ||
print('Division by zero is illegal') | ||
else: | ||
raise ##will raise the exception it catched | ||
except TypeError: | ||
print("That is not a valid number") | ||
except (KeyError, ValueError) as error: | ||
##you can determine the type of error!!! | ||
##就像js的事件委托的回调一样 | ||
print(error) | ||
print("some message") | ||
except: | ||
print("i catch all exceptions left") | ||
else: | ||
print("ok! nothing wrong happens. wowowo") | ||
finally: | ||
print("to be or not to be , i will always be there!!!!") | ||
print("I will do some cleaning") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
## yield 和 return 的作用的异同 | ||
|
||
def flatten(nested): | ||
try: | ||
for sublist in nested: | ||
for element in flatten(sublist): | ||
##这里的语句会被执行吗 | ||
yield element | ||
except TypeError: | ||
yield nested | ||
|
||
def error(): | ||
time = 0 | ||
while time < 10: | ||
try: | ||
if time % 2 == 0: | ||
raise Exception | ||
else: | ||
print(time) | ||
except: | ||
print('no') | ||
time+=1 | ||
error() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
def isPrime(num): | ||
for i in range(2, int(num ** 0.5) + 1): | ||
if num % i == 0: | ||
return False | ||
return True | ||
|
||
class Prime: | ||
def __init__(self, max): | ||
self.max = max | ||
self.number = 1 | ||
def __iter__(self): | ||
return self | ||
def __next__(self): | ||
self.number+=1 | ||
if self.number >= self.max: | ||
raise StopIteration | ||
elif isPrime(self.number): | ||
return self.number | ||
else: | ||
return self.__next__() | ||
|
||
test = Prime(999) | ||
for i in test: | ||
print(i) |
Oops, something went wrong.