GithubHelp home page GithubHelp logo

iswbm / magic-python Goto Github PK

View Code? Open in Web Editor NEW
3.2K 3.2K 473.0 22.13 MB

Python 黑魔法手册

Home Page: http://magic.iswbm.com/

Python 86.14% Batchfile 3.80% JavaScript 1.20% Makefile 3.03% HTML 3.99% Shell 1.83%

magic-python's Introduction

微信 GitHub stars GitHub issues Build Status

关于本书

本书是一本专门介绍 Python 黑魔法玩法的电子书。其中包括少有人知的一些 Python 冷门知识,Python Shell 的多样玩法,各种令人疯狂的 Python 炫技操作,Python 的超详细进阶知识解读,还有不断扩充完善适合所有 Python 开发者的开发技巧等等。

本书旨在向你介绍一个不一样的 Python,而不是一份初学者的 Python 基础教学资料。

如何开始

阅读本书有两个入口:

  1. 在线阅读:实时更新最新内容,链接:Python黑魔法手册

  2. 离线阅读:到 Release 下载最新版的 PDF

我的电子书

我写过四个在线文件,分别是:

  1. Python 黑魔法指南》:https://magic.iswbm.com/

  2. PyCharm 中文指南》:https://pycharm.iswbm.com/

  3. Python 中文指南》:https://python.iswbm.com/

  4. Go 编程时光 - 入门宝典》:https://golang.iswbm.com/

有兴趣的,可以点击链接了解一下。

目录大纲

写在最后

本书所有文章均为本人原创,若对你学习 Python 有帮助,希望你能多多帮忙宣传,让更多的人知道这本书。

如果你有不错的内容,想加入进来,可以提交 pull requests ,大家一起努力作好这个项目。

magic-python's People

Contributors

imba-tjd avatar iswbm avatar neutron3529 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

magic-python's Issues

3.11节小问题

3.9.2下,io.open和open应该是一个函数,os.open才应该是底层的文件I/O流

Python 3.9.2 (default, Feb 28 2021, 17:03:44) 
[GCC 10.2.1 20210110] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import os
>>> (open1:=open) is (open2:=os.open)
False
>>> import io
>>> (open3:=open) is (open3:=io.open)
True

为微信引流的行为比较ex

rt,我还以为就其它社交平台给的网盘里压缩包有密码和二维码,结果连release给的压缩包也是,扫码进去吧,还说什么取关过,得加微信好友才行,就这?挺反感的就是

示例不严谨

第二节,end的使用方法,你的示例中不管那种都必被if或者else捕获,然后直接return,压根就走不到end的地方,我没有亲自实验,但是没报错不能说明这个东西有用,只能证明这个东西没有报错,请考虑一个严谨的例子。不然怕是误人误己

numba 示例代码报错

http://magic.iswbm.com/zh/latest/c07/c07_05.html#id1

python 3.8.5 32bit , numba 0.52.0

from numba import jit
import time


@jit
def foo(x, y):
    tt = time.time()
    s = 0
    for i in range(x, y):
        s += i
    print("Time used: {} sec".format(time.time() - tt))
    return s


print(foo(1, 100000000))
c:\Users\wuyudi\Desktop\新建 Python File (3).py:5: NumbaWarning: 
Compilation is falling back to object mode WITH looplifting enabled because Function "foo" failed type inference due to: Unknown attribute 'time' of type Module(<module 'time' (built-in)>)

File "Desktop\新建 Python File (3).py", line 7:
def foo(x, y):
    tt = time.time()
    ^

During: typing of get attribute at c:\Users\wuyudi\Desktop\新建 Python File (3).py (7)

File "Desktop\新建 Python File (3).py", line 7:
def foo(x, y):
    tt = time.time()
    ^

  @jit
c:\Users\wuyudi\Desktop\新建 Python File (3).py:5: NumbaWarning: 
Compilation is falling back to object mode WITHOUT looplifting enabled because Function "foo" failed type inference due to: Cannot determine Numba type of <class 'numba.core.dispatcher.LiftedLoop'>

File "Desktop\新建 Python File (3).py", line 9:
def foo(x, y):
    <source elided>
    s = 0
    for i in range(x, y):
    ^

  @jit
D:\Program Files\Python3.8.5\lib\site-packages\numba\core\object_mode_passes.py:151: NumbaWarning: Function "foo" was compiled in object mode without forceobj=True, but has lifted loops.

File "Desktop\新建 Python File (3).py", line 7:
def foo(x, y):
    tt = time.time()
    ^

  warnings.warn(errors.NumbaWarning(warn_msg,
D:\Program Files\Python3.8.5\lib\site-packages\numba\core\object_mode_passes.py:161: NumbaDeprecationWarning: 
Fall-back from the nopython compilation path to the object mode compilation path has been detected, this is deprecated behaviour.

For more information visit https://numba.pydata.org/numba-doc/latest/reference/deprecation.html#deprecation-of-object-mode-fall-back-behaviour-when-using-jit

File "Desktop\新建 Python File (3).py", line 7:
def foo(x, y):
    tt = time.time()
    ^

  warnings.warn(errors.NumbaDeprecationWarning(msg,
Time used: 0.12804293632507324 sec
887459712

5.6 中的简化臃肿代码可以使用海象运算符

def read_from_file(filename: str, block_size: int = 1024 * 8) -> iter:
    with open(filename, "r") as fp:
        while chunk := fp.read(block_size):
            yield chunk

使用 Python3.8 中的海象运算符可以使函数更加易读。

中英文搜索

感谢分享,请问Sphinx中英文搜索在conf.py中如何设置呢?

1.15中的shebang

所以当我在 /usr/local/sbin 下创建一个名字也为 python 的可执行文件时,就会执行 /usr/bin/python 了。

在/usr/local/sbin下创建名为python的可执行文件,执行的不应该是/usr/local/sbin/python吗?

魔法冷知识中的几个问题

10.哪些情况下不需要续行符 中:

在多行文本注释中,续行符也是可以不写的,但是会变成\n。

text = '''talk is cheap, show me the code.'''

输出:'talk is cheap,\nshow me the code.'

11.用户无感知的小整数池

在同一行里,同时给两个变量赋同一值时,结果依然为False。

a = 257; b = 257 a is b

输出:False

12.神器的intern机制

如果一个字符串长度超过20个字符,不启动intern机制,这个数字好像不是20

s1 = "a"*100 s2 = "a"*100 s1 is s2

输出:True

s1 = "a"*10001 s2 = "a"*10001 s1 is s2

输出:False

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.