Discuz! Board

 找回密码
 立即注册
搜索
热搜: 活动 交友 discuz

python3学习笔记---hzh

查看数: 1025 | 评论数: 14 | 收藏 0
关灯 | 提示:支持键盘翻页<-左 右->
    组图打开中,请稍候......
发布时间: 2024-5-26 18:32

正文摘要:

本帖最后由 doraemon 于 2024-5-26 22:47 编辑 学习笔记11

回复

doraemon 发表于 2024-6-23 19:35:22

列表 list             可以数字,字符一起
[1,2,3,4,5,6]          另一种编程叫二维数组
                    在Python叫嵌套列表


[“A”,”B”,”C”,”D”][3]              [“A”,”B”,”C”,”D”]+[E]           [“A”]*3   
=‘C’                          =‘[“A”,”B”,”C”,”D”,“E”’         =  “A,A,A”  




tuple 元组,数组;         (1,2,3)        

((1))表示元组也表示运算:(1+1)*2=4
表示空元组:type([1])
           =list   

Len多少
max多大      

Set集合 {}
dict字典; 词典
doraemon 发表于 2024-6-22 14:34:07
type(1*1)
<class 'int'>
type(1*1.0)
<class 'float'>
type(2/2)
<class 'float'>
type(2//2)
<class 'int'>
doraemon 发表于 2024-6-22 14:30:35
doraemon 发表于 2024-6-14 23:51
type([1])

int,float,bool,str,list,tuple

type(2//2)
<class 'int'>
type(2/2)
<class 'float'>
2/2
1.0
2//2
1
1/2
0.5
1//2
0
python3 not python2. long
doraemon 发表于 2024-6-16 11:46:02
在这python3里面不会像其他编程有一键清除 如下
clear
Traceback (most recent call last):
  File "<pyshell#1>", line 1, in <module>
    clear
NameError: name 'clear' is not defined
最好的方法是关了python3再开一遍
doraemon 发表于 2024-6-15 11:44:29
doraemon 发表于 2024-6-14 23:51
type([1])

int,float,bool,str,list,tuple
len([1,2,3,4,5,6])
6
len("hello world")
11
3 in [1,2,3,4,5,6]
True
10 in [1,2,3,4,5,6]
False
3 not in [1,2,3,4,5,6]
False
max([1,2,3,4,5,6])
6
min([1,2,3,4,5,6])
1
max("hello world")
'w'
doraemon 发表于 2024-6-14 23:51:04
doraemon 发表于 2024-6-14 23:39
int ;国际性组织(International organizations);整数(integer,编程语言中的数据类型);感叹词(inte ...

type([1])
<class 'list'>
int,float,bool,str,list,tuple
(<class 'int'>, <class 'float'>, <class 'bool'>, <class 'str'>, <class 'list'>, <class 'tuple'>)
str  list  tuple  序列
'hello world'[2]
[1,2,3][2]
3
[1,2,3,4,5][0:3]
[1, 2, 3]
[1,2,3,4,5][-1:]
[5]
"hello world"[0:8:2]
'hlow'
doraemon 发表于 2024-6-14 23:39:35
本帖最后由 doraemon 于 2024-6-14 23:41 编辑

int ;国际性组织(International organizations);整数(integer,编程语言中的数据类型);感叹词(interjection的缩写)                                                                                                                                                                                          float ;v. 浮动;漂浮;提出,提请考虑(想法或计划);(使货币汇率)自由浮动;使漂流;飘动;飘移;(公司或企业)发行(股票)上市;轻盈走动                              
n.浮子;(学游泳用的)浮板;彩车;鱼漂;(商店的)备用零钱;加冰激凌的饮料           复数:floats第三人称单数:  floats现在进行时:  floating过去式:  floated过去分词:  floated                                                                    
bool n.布尔;<英方>弯曲件                                                                                                      
str abbr.(=submarine thermal reactor)潜水艇用热中子反应堆                                                                    
list n.列表;清单;名单;目录;一览表;(船的)倾斜                                                                             
v.(按某次序)把…列表,列清单,拟订清单; 列举; (向一侧)倾斜; (被)列入销售清单,列入价目表; 把…列入一览表
tuple  n.元组;元组,数组                                                                                                      
单词意思  以上都是                                                                  
doraemon 发表于 2024-6-14 23:15:56

type((1))
<class 'int'>
(1+1)*2
4
type((1))
<class 'int'>
type(1)
<class 'int'>
(1,2,3)
(1, 2, 3)
(1)
1
(1,)
(1,)
type((1,))
<class 'tuple'>
doraemon 发表于 2024-6-14 23:12:44
doraemon 发表于 2024-6-14 23:09
(1,2,3,4,5)
(1, 2, 3, 4, 5)
(1,'-1',True)

type((1,2,3))
<class 'tuple'>
type(1)
<class 'int'>
type([1,2,3])
<class 'list'>
type('hello')
<class 'str'>
type((1))
<class 'int'>
type(('hello'))
<class 'str'>

QQ|Archiver|手机版|小黑屋|firemail ( 粤ICP备15085507号-1 )

GMT+8, 2024-9-28 06:12 , Processed in 0.060430 second(s), 21 queries .

Powered by Discuz! X3

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表