bug320 / my-python-wiki Goto Github PK
View Code? Open in Web Editor NEWonly for learn
only for learn
# 说明 --- 文件名 | 说明 :------------: | :-----------------: build-function | 內建函数,系统记录 data-struct | 内置数据结构 class-object | 类和对象 os-sys | 系统相关 other | 其他 --- `build-function` 负责记录零散的內建函数,给出用法和例子。按照函数名首字母排序。 `data-struct` 负责记录 python 内置的数据对象,和相关方法。 `class-object` 负责记录类相关的知识和用法 `os-sys` 负责记录系统文件的操作 `other` 负责记录一些零散的心得体会
all(...)
all(iterable) -> bool
Return True if bool(x) is True for all values x in the iterable.
If the iterable is empty, return True.
myall()相当于 内置的 all() 函数
如果 iterable 为空 或者 iterate 内全部元素为 True
(即非空) 返回 True
,
否则,如果 iterable 内部有一个为 False
(相当于c语言中的 NULL
),返回 Flase
def myall(iterable):
for element in iterable:
if not element:
return False
return True
any(...)
any(iterable) -> bool
Return True if bool(x) is True for any x in the iterable.
If the iterable is empty, return False.
myany()相当于 内置的 any() 函数
如果,如果 iterable 内任一个元素不为假("",0,False
),返回 True
否则,如果 iterable 为空 或者 iterable 内全部元素为假 ,返回 False
def myany(iterable):
for element in iterable:
if element :
return True
return False
if __name__ == "__main__":
no_null = ['a','b','c','d']
all_null = [0,False,'']
is_null =[]
one_null = ['a','','c','d']
one_sz_zero = ['a','0','c','d']
one_num_zero = ['a',0,'c','d']
print "any"
print ""
print any(no_null) # True
print any(all_null) # False
print any(is_null) # False
print any(one_null) # True
print any(one_sz_zero) # True
print any(one_num_zero) # True
print ""
print "myany"
print ""
print myany(no_null) # False
print myany(all_null) # True
print myany(is_null) # True
print myany(one_null) # False
print myany(one_sz_zero) # False
print myany(one_num_zero) # False
print "all"
print ""
print all(no_null) # True
print all(all_null) # False
print all(is_null) # True
print all(one_null) # False
print all(one_sz_zero) # True
print all(one_num_zero) # False
print ""
print "myall"
print ""
print myall(no_null) # True
print myall(all_null) # False
print myall(is_null) # True
print myall(one_null) # False
print myall(one_sz_zero) # True
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.