- Mastering Python Networking
- Eric Chou
- 137字
- 2021-07-02 21:42:33
Python operators
Python has the some numeric operators that you would expect; note that the truncating division, (//, also known as floor division) truncates the result to an integer and a floating point and return the integer value. The integer value is returned. The modulo (%) operator returns the remainder value in the division:
>>> 1 + 2
3
>>> 2 - 1
1
>>> 1 * 5
5
>>> 5 / 1
5.0
>>> 5 // 2
2
>>> 5 % 2
1
There are also comparison operators:
>>> a = 1
>>> b = 2
>>> a == b
False
>>> a > b
False
>>> a < b
True
>>> a <= b
True
We will also see two of the common membership operators to see whether an object is in a sequence type:
>>> a = 'hello world'
>>> 'h' in a
True
>>> 'z' in a
False
>>> 'h' not in a
False
>>> 'z' not in a
True
推薦閱讀
- 程序員修煉之道:程序設(shè)計入門30講
- Python Deep Learning
- 高級C/C++編譯技術(shù)(典藏版)
- Python應(yīng)用輕松入門
- HTML5+CSS3網(wǎng)站設(shè)計教程
- Corona SDK Mobile Game Development:Beginner's Guide(Second Edition)
- Mastering Docker
- IoT Projects with Bluetooth Low Energy
- Android Studio開發(fā)實戰(zhàn):從零基礎(chǔ)到App上線 (移動開發(fā)叢書)
- Monitoring Docker
- Scratch編程從入門到精通
- Python計算機視覺與深度學(xué)習(xí)實戰(zhàn)
- 青少年P(guān)ython趣味編程
- INSTANT EaselJS Starter
- HTML 5與CSS 3權(quán)威指南(第3版·下冊)