Error[8]: Undefined offset: 16, File: /www/wwwroot/outofmemory.cn/tmp/plugin_ss_superseo_model_superseo.php, Line: 121
File: /www/wwwroot/outofmemory.cn/tmp/plugin_ss_superseo_model_superseo.php, Line: 473, decode(

1.注释的两种类型

单行注释:#(ctrl+/ 选择多行分别注释)

多行注释:“”“     ”“”(三个引号)

2.一般输出方式

核心准则:不同类型(比如字符串和整形)用英文逗号连接,对应于代码中的age部分;同种类型用加号连接。

name=input("输入姓名:")
age=18
print("hello啊,我叫"+name+","+"今年岁",age,","+"多多指教!")

程序运行结果:

输入姓名:wlpy
hello啊,我叫wlpy,今年岁 18 ,多多指教!

注:打印内容涉及转义符“\” ,在字符串前加"r'(反转义):

print("你好“你好print(r"你好你好name=input("输入姓名:")
age=18
print("hello啊,我叫{},今年{}岁,多多指教!".format(name,18))
print("hello啊,我叫%s,今年%s岁,多多指教!"%(name,18))
print(f"hello啊,我叫{name},今年{age}岁,多多指教!")帅哥!帅哥!")帅哥!”帅哥!")

 不会输出:输入姓名:wlpy hello啊,我叫wlpy,今年18岁,多多指教! hello啊,我叫wlpy,今年18岁,多多指教! hello啊,我叫wlpy,今年18岁,多多指教!

lit1 = [1,2,3,4]
lit2 = [5,6,7]
lit1.extend(lit2)
print(lit1)
[1, 2, 3, 4, 5, 6, 7]

3.格式化输出

格式化输出的三种方法:

lit1 = [1,2,3,4]
# pop()删除元素
lit1.pop()
print(lit1)
# remove()删除
lit2 = [1,2,3,4]
lit2.remove(2)
print(lit2)
# del 删除
lit3 = [1,2,3,4]
del lit3[1]
print(lit3)

程序运行结果:

[1, 2, 3]
[1, 3, 4]
[1, 3, 4]
4.序列类型之列表 1.列表的定义

直接用列表的符号定义列表list1=[]或关键字定义列表ist1=list()

2.列表的 *** 作之增删改查

1.添加元素:list1.append()  默认将元素加入到列表末尾

                     list1.insert(,)  指定下标插入元素

                     list1.extend()   合并迭代对象

extend()函数示例:

for i in range(1,11,2):
    print(i,end=",")

输出:

1,3,5,7,9,

 2.删除元素:list1.pop()   默认删除末尾元素

                      list1.remove()     括号内填写元素名称直接指定删除

                      del list1[]   索引删除元素

示例:

lit = ["你好","帅哥","交个朋友撒"]
for i in lit:
    print(i,end='')

输出: 

你好帅哥交个朋友撒

3.更改元素(位置,元素) 

·位置:list1.sort()排序函数,默认reverse=False从小到大,可以写入reverse=True从大到小排序。两种反序方法:reverse()和切片[::-1]

·元素更改且不改变元素的位置:步一索引元素位置data = list1.index()

                                                   步二原位置添加元素list1.insert(data,元素)

5.for循环

1.for i in range(a,b,c)   由a到b-1步长为c,范围[a,b-1)

[+++]

   输出:

[+++]

2.for 变量名 in 容器,遍历容器内的所有元素

[+++]

输出:

[+++]
6.零碎但很实用的知识点

1.在敲代码时,要养成写注释的习惯

2.名称命名法多采用大小驼峰法name_give

3.命名规则:数字字母下划线,数组不能在开头,空格要用下划线来代替,避免关键字

)
File: /www/wwwroot/outofmemory.cn/tmp/route_read.php, Line: 126, InsideLink()
File: /www/wwwroot/outofmemory.cn/tmp/index.inc.php, Line: 166, include(/www/wwwroot/outofmemory.cn/tmp/route_read.php)
File: /www/wwwroot/outofmemory.cn/index.php, Line: 30, include(/www/wwwroot/outofmemory.cn/tmp/index.inc.php)
Error[8]: Undefined offset: 17, File: /www/wwwroot/outofmemory.cn/tmp/plugin_ss_superseo_model_superseo.php, Line: 121
File: /www/wwwroot/outofmemory.cn/tmp/plugin_ss_superseo_model_superseo.php, Line: 473, decode(

1.注释的两种类型

单行注释:#(ctrl+/ 选择多行分别注释)

多行注释:“”“     ”“”(三个引号)

2.一般输出方式

核心准则:不同类型(比如字符串和整形)用英文逗号连接,对应于代码中的age部分;同种类型用加号连接。

name=input("输入姓名:")
age=18
print("hello啊,我叫"+name+","+"今年岁",age,","+"多多指教!")

程序运行结果:

输入姓名:wlpy
hello啊,我叫wlpy,今年岁 18 ,多多指教!

注:打印内容涉及转义符“\” ,在字符串前加"r'(反转义):

print("你好“你好print(r"你好你好name=input("输入姓名:")
age=18
print("hello啊,我叫{},今年{}岁,多多指教!".format(name,18))
print("hello啊,我叫%s,今年%s岁,多多指教!"%(name,18))
print(f"hello啊,我叫{name},今年{age}岁,多多指教!")帅哥!帅哥!")帅哥!”帅哥!")

 不会输出:输入姓名:wlpy hello啊,我叫wlpy,今年18岁,多多指教! hello啊,我叫wlpy,今年18岁,多多指教! hello啊,我叫wlpy,今年18岁,多多指教!

lit1 = [1,2,3,4]
lit2 = [5,6,7]
lit1.extend(lit2)
print(lit1)
[1, 2, 3, 4, 5, 6, 7]

3.格式化输出

格式化输出的三种方法:

lit1 = [1,2,3,4]
# pop()删除元素
lit1.pop()
print(lit1)
# remove()删除
lit2 = [1,2,3,4]
lit2.remove(2)
print(lit2)
# del 删除
lit3 = [1,2,3,4]
del lit3[1]
print(lit3)

程序运行结果:

[1, 2, 3]
[1, 3, 4]
[1, 3, 4]
4.序列类型之列表 1.列表的定义

直接用列表的符号定义列表list1=[]或关键字定义列表ist1=list()

2.列表的 *** 作之增删改查

1.添加元素:list1.append()  默认将元素加入到列表末尾

                     list1.insert(,)  指定下标插入元素

                     list1.extend()   合并迭代对象

extend()函数示例:

for i in range(1,11,2):
    print(i,end=",")

输出:

1,3,5,7,9,

 2.删除元素:list1.pop()   默认删除末尾元素

                      list1.remove()     括号内填写元素名称直接指定删除

                      del list1[]   索引删除元素

示例:

lit = ["你好","帅哥","交个朋友撒"]
for i in lit:
    print(i,end='')

输出: 

你好帅哥交个朋友撒

3.更改元素(位置,元素) 

·位置:list1.sort()排序函数,默认reverse=False从小到大,可以写入reverse=True从大到小排序。两种反序方法:reverse()和切片[::-1]

·元素更改且不改变元素的位置:步一索引元素位置data = list1.index()

                                                   步二原位置添加元素list1.insert(data,元素)

5.for循环

1.for i in range(a,b,c)   由a到b-1步长为c,范围[a,b-1)

 

   输出:

[+++]

2.for 变量名 in 容器,遍历容器内的所有元素

[+++]

输出:

[+++]
6.零碎但很实用的知识点

1.在敲代码时,要养成写注释的习惯

2.名称命名法多采用大小驼峰法name_give

3.命名规则:数字字母下划线,数组不能在开头,空格要用下划线来代替,避免关键字

)
File: /www/wwwroot/outofmemory.cn/tmp/route_read.php, Line: 126, InsideLink()
File: /www/wwwroot/outofmemory.cn/tmp/index.inc.php, Line: 166, include(/www/wwwroot/outofmemory.cn/tmp/route_read.php)
File: /www/wwwroot/outofmemory.cn/index.php, Line: 30, include(/www/wwwroot/outofmemory.cn/tmp/index.inc.php)
Error[8]: Undefined offset: 18, File: /www/wwwroot/outofmemory.cn/tmp/plugin_ss_superseo_model_superseo.php, Line: 121
File: /www/wwwroot/outofmemory.cn/tmp/plugin_ss_superseo_model_superseo.php, Line: 473, decode(

1.注释的两种类型

单行注释:#(ctrl+/ 选择多行分别注释)

多行注释:“”“     ”“”(三个引号)

2.一般输出方式

核心准则:不同类型(比如字符串和整形)用英文逗号连接,对应于代码中的age部分;同种类型用加号连接。

name=input("输入姓名:")
age=18
print("hello啊,我叫"+name+","+"今年岁",age,","+"多多指教!")

程序运行结果:

输入姓名:wlpy
hello啊,我叫wlpy,今年岁 18 ,多多指教!

注:打印内容涉及转义符“\” ,在字符串前加"r'(反转义):

print("你好“你好print(r"你好你好name=input("输入姓名:")
age=18
print("hello啊,我叫{},今年{}岁,多多指教!".format(name,18))
print("hello啊,我叫%s,今年%s岁,多多指教!"%(name,18))
print(f"hello啊,我叫{name},今年{age}岁,多多指教!")帅哥!帅哥!")帅哥!”帅哥!")

 不会输出:输入姓名:wlpy hello啊,我叫wlpy,今年18岁,多多指教! hello啊,我叫wlpy,今年18岁,多多指教! hello啊,我叫wlpy,今年18岁,多多指教!

lit1 = [1,2,3,4]
lit2 = [5,6,7]
lit1.extend(lit2)
print(lit1)
[1, 2, 3, 4, 5, 6, 7]

3.格式化输出

格式化输出的三种方法:

lit1 = [1,2,3,4]
# pop()删除元素
lit1.pop()
print(lit1)
# remove()删除
lit2 = [1,2,3,4]
lit2.remove(2)
print(lit2)
# del 删除
lit3 = [1,2,3,4]
del lit3[1]
print(lit3)

程序运行结果:

[1, 2, 3]
[1, 3, 4]
[1, 3, 4]
4.序列类型之列表 1.列表的定义

直接用列表的符号定义列表list1=[]或关键字定义列表ist1=list()

2.列表的 *** 作之增删改查

1.添加元素:list1.append()  默认将元素加入到列表末尾

                     list1.insert(,)  指定下标插入元素

                     list1.extend()   合并迭代对象

extend()函数示例:

for i in range(1,11,2):
    print(i,end=",")

输出:

1,3,5,7,9,

 2.删除元素:list1.pop()   默认删除末尾元素

                      list1.remove()     括号内填写元素名称直接指定删除

                      del list1[]   索引删除元素

示例:

lit = ["你好","帅哥","交个朋友撒"]
for i in lit:
    print(i,end='')

输出: 

你好帅哥交个朋友撒

3.更改元素(位置,元素) 

·位置:list1.sort()排序函数,默认reverse=False从小到大,可以写入reverse=True从大到小排序。两种反序方法:reverse()和切片[::-1]

·元素更改且不改变元素的位置:步一索引元素位置data = list1.index()

                                                   步二原位置添加元素list1.insert(data,元素)

5.for循环

1.for i in range(a,b,c)   由a到b-1步长为c,范围[a,b-1)

 

   输出:

 

2.for 变量名 in 容器,遍历容器内的所有元素

[+++]

输出:

[+++]
6.零碎但很实用的知识点

1.在敲代码时,要养成写注释的习惯

2.名称命名法多采用大小驼峰法name_give

3.命名规则:数字字母下划线,数组不能在开头,空格要用下划线来代替,避免关键字

)
File: /www/wwwroot/outofmemory.cn/tmp/route_read.php, Line: 126, InsideLink()
File: /www/wwwroot/outofmemory.cn/tmp/index.inc.php, Line: 166, include(/www/wwwroot/outofmemory.cn/tmp/route_read.php)
File: /www/wwwroot/outofmemory.cn/index.php, Line: 30, include(/www/wwwroot/outofmemory.cn/tmp/index.inc.php)
Error[8]: Undefined offset: 19, File: /www/wwwroot/outofmemory.cn/tmp/plugin_ss_superseo_model_superseo.php, Line: 121
File: /www/wwwroot/outofmemory.cn/tmp/plugin_ss_superseo_model_superseo.php, Line: 473, decode(

1.注释的两种类型

单行注释:#(ctrl+/ 选择多行分别注释)

多行注释:“”“     ”“”(三个引号)

2.一般输出方式

核心准则:不同类型(比如字符串和整形)用英文逗号连接,对应于代码中的age部分;同种类型用加号连接。

name=input("输入姓名:")
age=18
print("hello啊,我叫"+name+","+"今年岁",age,","+"多多指教!")

程序运行结果:

输入姓名:wlpy
hello啊,我叫wlpy,今年岁 18 ,多多指教!

注:打印内容涉及转义符“\” ,在字符串前加"r'(反转义):

print("你好“你好print(r"你好你好name=input("输入姓名:")
age=18
print("hello啊,我叫{},今年{}岁,多多指教!".format(name,18))
print("hello啊,我叫%s,今年%s岁,多多指教!"%(name,18))
print(f"hello啊,我叫{name},今年{age}岁,多多指教!")帅哥!帅哥!")帅哥!”帅哥!")

 不会输出:输入姓名:wlpy hello啊,我叫wlpy,今年18岁,多多指教! hello啊,我叫wlpy,今年18岁,多多指教! hello啊,我叫wlpy,今年18岁,多多指教!

lit1 = [1,2,3,4]
lit2 = [5,6,7]
lit1.extend(lit2)
print(lit1)
[1, 2, 3, 4, 5, 6, 7]

3.格式化输出

格式化输出的三种方法:

lit1 = [1,2,3,4]
# pop()删除元素
lit1.pop()
print(lit1)
# remove()删除
lit2 = [1,2,3,4]
lit2.remove(2)
print(lit2)
# del 删除
lit3 = [1,2,3,4]
del lit3[1]
print(lit3)

程序运行结果:

[1, 2, 3]
[1, 3, 4]
[1, 3, 4]
4.序列类型之列表 1.列表的定义

直接用列表的符号定义列表list1=[]或关键字定义列表ist1=list()

2.列表的 *** 作之增删改查

1.添加元素:list1.append()  默认将元素加入到列表末尾

                     list1.insert(,)  指定下标插入元素

                     list1.extend()   合并迭代对象

extend()函数示例:

for i in range(1,11,2):
    print(i,end=",")

输出:

1,3,5,7,9,

 2.删除元素:list1.pop()   默认删除末尾元素

                      list1.remove()     括号内填写元素名称直接指定删除

                      del list1[]   索引删除元素

示例:

lit = ["你好","帅哥","交个朋友撒"]
for i in lit:
    print(i,end='')

输出: 

你好帅哥交个朋友撒

3.更改元素(位置,元素) 

·位置:list1.sort()排序函数,默认reverse=False从小到大,可以写入reverse=True从大到小排序。两种反序方法:reverse()和切片[::-1]

·元素更改且不改变元素的位置:步一索引元素位置data = list1.index()

                                                   步二原位置添加元素list1.insert(data,元素)

5.for循环

1.for i in range(a,b,c)   由a到b-1步长为c,范围[a,b-1)

 

   输出:

 

2.for 变量名 in 容器,遍历容器内的所有元素

 

输出:

[+++]
6.零碎但很实用的知识点

1.在敲代码时,要养成写注释的习惯

2.名称命名法多采用大小驼峰法name_give

3.命名规则:数字字母下划线,数组不能在开头,空格要用下划线来代替,避免关键字

)
File: /www/wwwroot/outofmemory.cn/tmp/route_read.php, Line: 126, InsideLink()
File: /www/wwwroot/outofmemory.cn/tmp/index.inc.php, Line: 166, include(/www/wwwroot/outofmemory.cn/tmp/route_read.php)
File: /www/wwwroot/outofmemory.cn/index.php, Line: 30, include(/www/wwwroot/outofmemory.cn/tmp/index.inc.php)
Python 学习小 summary_python_内存溢出

Python 学习小 summary

Python 学习小 summary,第1张

1.注释的两种类型

单行注释:#(ctrl+/ 选择多行分别注释)

多行注释:“”“     ”“”(三个引号)

2.一般输出方式

核心准则:不同类型(比如字符串和整形)用英文逗号连接,对应于代码中的age部分;同种类型用加号连接。

name=input("输入姓名:")
age=18
print("hello啊,我叫"+name+","+"今年岁",age,","+"多多指教!")

程序运行结果:

输入姓名:wlpy
hello啊,我叫wlpy,今年岁 18 ,多多指教!

注:打印内容涉及转义符“\” ,在字符串前加"r'(反转义):

print("你好“你好print(r"你好你好name=input("输入姓名:")
age=18
print("hello啊,我叫{},今年{}岁,多多指教!".format(name,18))
print("hello啊,我叫%s,今年%s岁,多多指教!"%(name,18))
print(f"hello啊,我叫{name},今年{age}岁,多多指教!")帅哥!帅哥!")帅哥!”帅哥!")

 不会输出:输入姓名:wlpy hello啊,我叫wlpy,今年18岁,多多指教! hello啊,我叫wlpy,今年18岁,多多指教! hello啊,我叫wlpy,今年18岁,多多指教!

lit1 = [1,2,3,4]
lit2 = [5,6,7]
lit1.extend(lit2)
print(lit1)
[1, 2, 3, 4, 5, 6, 7]

3.格式化输出

格式化输出的三种方法:

lit1 = [1,2,3,4]
# pop()删除元素
lit1.pop()
print(lit1)
# remove()删除
lit2 = [1,2,3,4]
lit2.remove(2)
print(lit2)
# del 删除
lit3 = [1,2,3,4]
del lit3[1]
print(lit3)

程序运行结果:

[1, 2, 3]
[1, 3, 4]
[1, 3, 4]
4.序列类型之列表 1.列表的定义

直接用列表的符号定义列表list1=[]或关键字定义列表ist1=list()

2.列表的 *** 作之增删改查

1.添加元素:list1.append()  默认将元素加入到列表末尾

                     list1.insert(,)  指定下标插入元素

                     list1.extend()   合并迭代对象

extend()函数示例:

for i in range(1,11,2):
    print(i,end=",")

输出:

1,3,5,7,9,

 2.删除元素:list1.pop()   默认删除末尾元素

                      list1.remove()     括号内填写元素名称直接指定删除

                      del list1[]   索引删除元素

示例:

lit = ["你好","帅哥","交个朋友撒"]
for i in lit:
    print(i,end='')

输出: 

你好帅哥交个朋友撒

3.更改元素(位置,元素) 

·位置:list1.sort()排序函数,默认reverse=False从小到大,可以写入reverse=True从大到小排序。两种反序方法:reverse()和切片[::-1]

·元素更改且不改变元素的位置:步一索引元素位置data = list1.index()

                                                   步二原位置添加元素list1.insert(data,元素)

5.for循环

1.for i in range(a,b,c)   由a到b-1步长为c,范围[a,b-1)

 

   输出:

 

2.for 变量名 in 容器,遍历容器内的所有元素

 

输出:

 
6.零碎但很实用的知识点 

1.在敲代码时,要养成写注释的习惯

2.名称命名法多采用大小驼峰法name_give

3.命名规则:数字字母下划线,数组不能在开头,空格要用下划线来代替,避免关键字

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/langs/741433.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-04-28
下一篇 2022-04-28

发表评论

登录后才能评论

评论列表(0条)

保存