CPython,用 C 和 Python 编写的,将 Python 代码编译成字节码,同时使用编译器和解释器
JPython,在 Java 平台上运行 Python 代码
Brython,在浏览器上运行,类似于 JavaScript
MicroPython,适用于微控制器
5、运行慢但仍然是最常用的语言之一
6、一切皆引用(reference)
7、在火星上运行(Running On Mars),这一点是什么鬼哦
You will get surprised to know that python is running on mars. Texting robots on Mars using python to send images to the earth. It uses request module to communicate with the API on mars.
import this# The Zen of Python, by Tim Peters# Beautiful is better than ugly.# Explicit is better than implicit.# Simple is better than complex.# Complex is better than complicated.# Flat is better than nested.# Sparse is better than dense.# Readability counts.# Special cases aren't special enough to break the rules.# Although practicality beats purity.# Errors should never pass silently.# Unless explicitly silenced.# In the face of ambiguity, refuse the temptation to guess.# There should be one-- and preferably only one --obvious way to do it.# Although that way may not be obvious at first unless you're Dutch.# Now is better than never.# 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.# Namespaces are one honking great idea -- let's do more of those!
import argparseparser = argparse.ArgumentParser(prog='top', description='Show top lines from the file')parser.add_argument('-l', '--lines', type=int, default=10)args = parser.parse_args()
5、re
这个无需多说,正则匹配是很强大一个库
6、math
说实话,这个库我用的很少很少
尽管里面有很多关于数学计算的函数,但是我用到的时候很少
import mathmath.log(1024, 2)
7、statistics
虽然是个内置标准库,但这个库没听过,更别说用过 2333
import statistics as stst.mean(data)st.median(data)st.variance(data)
8、urllib
一般都是用 requests 库去了,基本没咋用这个库
9、datetime
计算时间经常用到,但是总和 time 纠缠不清,每次都要去查
import datetime as dtnow = dt.date.today()print(now.year)print(now.month)
x = [True,True,False]ifany(x):print("At least one True")ifall(x):print("None False")ifany(x)andnotall(x):print("At least one True and one False")
2、bashplotlib
可以在控制台画图,一个三方库
3、Collections
我知道这个库里面有很多好用的模块,比如我用过的有 namedtuple 和 defaultdict
from collections import OrderedDict, Counter# memorize the order of adding keysx =OrderedDict(a=1, b=2, c=3)# count the frequency of each charactery =Counter("Hello World!")
4、dir
这个在前面的某一篇文章中介绍过,用来查看 Python对象的内部属性
5、emoji
用来展示 emoji 的三方库
from emoji import emojizeprint(emojize(": thumbs_up:"))
6、__future__
这个库里面也有很多好用的模块
7、geopy
从一系列不同的地理编码服务中提取 api 来获得该地点的完整地址、其纬度、经度,甚至其海拔高度
from geopy import GoogleV3place ="37 Tavistock Pl, Saint Pancras, London"location =GoogleV3().geocode(place)print(location.address)print(location.location)
dictionary ={"a":1,"b":2}defsomeFunction(a,b):print(a + b)return# 2 applications of the function aFunction identical:someFunction(**dictionary)someFunction(a=1, b=2)