python入门基础<1>

2018-11-08  本文已影响0人  苹果上的小豌豆

1.Python下载

2.安装。

3.打开IDLE.


4语法Python 基础教程

int,float,bool,str,list,tuple

序列。

in 和  not in

 

>>> ord("那")

37027

>>> ord("剧")

21095

>>>

集合set(无序的,排他性)

type({1,2,3})

<class 'set'>

{1,1,3,4,6,4}

{1, 3, 4, 6}

>>>

{1, 3, 4, 6} - {1}

{3, 4, 6}

>>> {1, 3, 4, 6} - {1,3}

{4, 6}

>>> {1, 3, 4, 6} & {3}

{3}

>>> {1, 3, 4, 6} | {9}

{1, 3, 4, 6, 9}

>>>

dict 字典

字典也没有序列
type({1:1,2:3})

<class 'dict'>

>>> {"name":"jack","sex":"men"}["name"]

'jack'

>>> a = "what"

>>> a = a + " are  you"

>>> print(a)

what are  you

>>>

逻辑运算符

>>> 2 and 8

8

>>> 2 or 8

2

>>> 2 not 8

SyntaxError: invalid syntax

>>> not 8

False


>>> a = 2

>>> a *=2

>>> print(a)

4

isinstance(a,str)

False

not > and > or 优先级

上一篇 下一篇

猜你喜欢

热点阅读