<Python Tips> 1. 介绍

2018-07-10  本文已影响13人  llitfk_DockOne

Python的特征与生态环境

Python环境搭建

注意: 简便起见,开发环境统一用Docker搭建, Docker for mac/win/linux, 安装详情请移步Docker贴士文集

运行Python程序

➜  ~ docker run --rm -ti python:alpine python
Python 3.7.0 (default, Jul  4 2018, 02:26:27) 
[GCC 6.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> 1 + 1
2
>>> 100 / 23
4.3478260869565215
>>> 2 ** 2048
32317006071311007300714876688669951960444102669715484032130345427524655138867890893197201411522913463688717960921898019494119559150490921095088152386448283120630877367300996091750197750389652106796057638384067568276792218642619756161838094338476170470581645852036305042887575891541065808607552399123930385521914333389668342420684974786564569494856176035326322058077805659331026192708460314150258592864177116725943603718461857357598351152301645904403697613233287231227125684710820209725157101726931323469678542580656697935045997268352998638215525166389437335543602135433229604645318478604952148193555853611059596230656
>>> 

Python代码组织与执行模型

代码组织
执行模型:

编写好的代码

PEP 8 -- Style Guide for Python Code

➜  ~ docker run --rm -ti python:alpine python
Python 3.7.0 (default, Jul  4 2018, 02:26:27) 
[GCC 6.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> 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!
>>> 
上一篇 下一篇

猜你喜欢

热点阅读