美文网首页
python入门基础<1>

python入门基础<1>

作者: 苹果上的小豌豆 | 来源:发表于2018-11-08 17:09 被阅读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 优先级

相关文章

网友评论

      本文标题:python入门基础<1>

      本文链接:https://www.haomeiwen.com/subject/wpdwxqtx.html