其他
Python 3中被忽视了的三大重要功能
The following article is from 读芯术 Author 读芯术
来自:公众号 读芯术 | 编辑:技术君
from enum importEnum
classState(Enum):
AIR=0
LAND=1
SEA=2
myState =State.AIR
# Prints 0
print(myState.value)
# Prints AIR
print(myState.name)
name = Brett
blog_title = Medium
# Hi, my name isBrett and I am writing on my Medium blog.
a ="Hi, myname is {} and I am writing on my {} blog.".format(name,blog_title)
name = Brett
blog_title = Medium
# Hi, my name isBrett and I am writing on my Medium blog.
a =f"Hi, myname is {name} and I am writing on my {blog_title} blog."
from dataclasses import dataclass
# Definedataclass
@dataclass
classVector3D:
x: int
y: int
z: int
# Create a vector
u =Vector3D(1,1,-1)
# Outputs: Vector3D(x=1,y=1, z=-1)
print(u)
--END--
往日热文:
这个GitHub 1400星的Git魔法书火了,斯坦福校友出品丨有中文版
API统一、干净,适配PyTorch、TF,新型EagerPy实现多框架无缝衔接
聚焦快速机器学习训练算法,UC伯克利尤洋189页博士论文公布
喜欢本文的朋友们,欢迎长按下图关注订阅号Python人工智能技术
收看更多精彩内容
你在看吗?一起成长