栏目分类:
子分类:
返回
终身学习网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
终身学习网 > IT > 软件开发 > 后端开发 > Python

2021-10-04-Learning notes P-4, Python

Python 更新时间:发布时间: 百科书网 趣学号

This article is the author's original, reproduced also please indicate the source.
This article only represents the author's own views, for reference only. If you have any objection, you are welcome to discuss.
Forrest
 

目录

1. Row connector

2. Object in python

-id()

-type()

-Example

Defination of object in python


1. Row connector

Row connector intend to connect two rows as one row in syntax.

Python 3.9.7 (v3.9.7:1016ef3790, Aug 30 2021, 16:25:35) 
[Clang 12.0.5 (clang-1205.0.22.11)] on darwin
Type "help", "copyright", "credits" or "license()" for more information.
>>> print("row-connector")
row-connector
>>> string = "abcdefghijklmnopqrstuvwxyz"
>>> string
'abcdefghijklmnopqrstuvwxyz'
>>> string_ = "abcdefgh"
SyntaxError: EOL while scanning string literal
>>> string2 = "abcdefgh
ijklmnopqrstuvwxy
z"
>>> string2
'abcdefghijklmnopqrstuvwxyz'
>>> array = [1, 34, 545, 67, 009, 4, 655303]
SyntaxError: leading zeros in decimal integer literals are not permitted; use an 0o prefix for octal integers
>>> array = [1, 34, 545, 67, 9, 4, 655303]
>>> array
[1, 34, 545, 67, 9, 4, 655303]
>>> array = [1, 3, 4
	 , 3, 4, 5, 3, 90]
>>> array
[1, 3, 4, 3, 4, 5, 3, 90]
>>> 

2. Object in python

As we all known, python is an objective programming language. 

Let us see two functions:

-id()

This funciton intends to show the address code of an object.

-type()

This one intends to show the type of the object. 

Futhermore, we could get more usages from the hint when you are coding. 

-Example
>>> string = "abcdefghijklmnopqrstuvwxyz"
>>> string
'abcdefghijklmnopqrstuvwxyz'

>>> string2 = "abcdefgh
ijklmnopqrstuvwxy
z"
>>> string2
'abcdefghijklmnopqrstuvwxyz'
>>> array = [1, 34, 545, 67, 9, 4, 655303]
>>> array
[1, 34, 545, 67, 9, 4, 655303]
>>> array = [1, 3, 4
	 , 3, 4, 5, 3, 90]
>>> array
[1, 3, 4, 3, 4, 5, 3, 90]
>>> 
>>> id(array)
4360215104
>>> type(array)

>>> id(string)
4350198288 # we can see here, the same string is from the same address!
>>> id(string2)
4350198288 # we can see here, the same string is from the same address!
>>> type(string)

>>> 

There is a funny findings, when you named, defined two variables with same value for example in the instance above the 'string' and 'string2' is the same content, and the address is same.

Defination of object in python

a block of memory, has its particular type and value, available for some relevant operations

The reference

Above example is from GaoQi sxt lesson video. 

转载请注明:文章转载自 www.051e.com
本文地址:http://www.051e.com/it/294765.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 ©2023-2025 051e.com

ICP备案号:京ICP备12030808号