0

0

Python的基本概念是什么?

王林

王林

发布时间:2023-08-31 22:09:10

|

1669人浏览过

|

来源于tutorialspoint

转载

python的基本概念是什么?

Python is a general-purpose interpreted, interactive, object-oriented, and high-level programming language.

Python的特点

以下是Python的主要特点:

  • Python支持函数式和结构化编程方法以及面向对象编程。

  • It can be used as a scripting language or can be compiled to byte-code for building large applications.

    立即学习Python免费学习笔记(深入)”;

  • It provides very high-level dynamic data types and supports dynamic type checking.

  • It supports automatic garbage collection.

Variables in Python

Variables are nothing but reserved memory locations to store values. This means that when you create a variable you reserve some space in memory. Let’s create a variable.

a = 10

上面,a是一个变量,赋值为整数10。

Numeric Datatype in Python

Number data types store numeric values. They are immutable data types, means that changing the value of a number data type results in a newly allocated object.

Python supports four different numerical types.

  • int (signed integers) − They are often called just integers or ints, are positive or negative whole numbers with no decimal point.

  • long (long integers ) − Also called longs, they are integers of unlimited size, written like integers and followed by an uppercase or lowercase L.

  • float (floating point real values) − Also called floats, they represent real numbers and are written with a decimal point dividing the integer and fractional parts. Floats may also be in scientific notation, with E or e indicating the power of 10 (2.5e2 = 2.5 x 102 = 250).

    全诚易惠通优惠打折管理系统
    全诚易惠通优惠打折管理系统

    全诚易惠通优惠折扣信息店铺管理系统是全诚团队继 “全诚商城”“外卖通” 之后又一新概念重量级作品,该系统以收集本地所有店铺优惠折扣信息为核心,在构思、设计、代码处理上都做了严密的部署和检查,继承了全诚系列产品核心模块的基础上进化而来,即为新作品,也系高度成熟度的作品,加之全诚团队精心技术支持,可为用户营造一个长期可靠的系统运行环境。本系统较易惠通相比,业务和经营范围覆盖面积更广更大,可涵盖本地所有

    下载
  • complex (complex numbers) − are of the form a + bJ, where a and b are floats and J (or j) represents the square root of -1 (which is an imaginary number). The real part of the number is a, and the imaginary part is b. Complex numbers are not used much in Python programming.

Strings in Python

字符串是Python中最受欢迎的类型之一。我们可以通过在引号中包含字符来简单地创建它们。Python将单引号和双引号视为相同。创建字符串就像将一个值赋给一个变量一样简单。

Let’s see how to easily create a String in Python.

myStr = Thisisit!'

Lists in Python

列表是Python中最多功能的数据类型,可以用方括号将逗号分隔的值(项)写成列表。让我们看看如何创建不同类型的列表。

myList1 = ['abc', 'pq'];
myList2 = [5, 10, 15, 20];

Tuples in Python

Tuples are sequences, just like lists. The differences between tuples and lists are, the tuples cannot be changed unlike lists and tuples use parentheses, whereas lists use square brackets.

Creating a tuple is as simple as putting different comma-separated values. Optionally you can put these comma-separated values between parentheses also. Let’s see how to create a Tuple.

myTuple1 = ('abc', 'pq)];
myTuple2 = (5, 10, 15, 20);

Dictionary in Python

字典是Python中的一种序列。在字典中,每个键都与其值用冒号(:)分隔,项之间用逗号分隔,并且整个字典被括在花括号中。字典中的键是唯一的,而值可能不是唯一的。字典的值可以是任何类型,但键必须是不可变的数据类型,例如字符串、数字或元组。

Let’s see how to create a Dictionary −

# Creating two Dictionaries
dict1 = {'Player':['Jacob','Steve','David','John','Kane'], 'Age':[29, 25, 31, 26, 27]}
dict2 = {'Rank':[1,2,3,4,5], 'Points':[100,87, 80,70, 50]}

Classes & Objects in Python

类是一个用户定义的对象原型,它定义了一组属性,这些属性描述了该类的任何对象。这些属性是数据成员和方法,通过点符号访问。

An object is a unique instance of a data structure that's defined by its class. An object comprises both data members (class variables and instance variables) and methods.

Functions in Python

function is a block of organized, reusable code that is used to perform a single, related action. Functions provide better modularity for your application and a high degree of code reusing.

函数块以关键字 def 开始,后跟函数名和括号 ( ( ) )。让我们创建一个函数。

def demo(s):
   print (s)
   return
# Function call
demo("Function Called")

输出

Function Called

相关文章

python速学教程(入门到精通)
python速学教程(入门到精通)

python怎么学习?python怎么入门?python在哪学?python怎么学才快?不用担心,这里为大家提供了python速学教程(入门到精通),有需要的小伙伴保存下载就能学习啦!

下载

相关标签:

本站声明:本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn

相关专题

更多
Golang gRPC 服务开发与Protobuf实战
Golang gRPC 服务开发与Protobuf实战

本专题系统讲解 Golang 在 gRPC 服务开发中的完整实践,涵盖 Protobuf 定义与代码生成、gRPC 服务端与客户端实现、流式 RPC(Unary/Server/Client/Bidirectional)、错误处理、拦截器、中间件以及与 HTTP/REST 的对接方案。通过实际案例,帮助学习者掌握 使用 Go 构建高性能、强类型、可扩展的 RPC 服务体系,适用于微服务与内部系统通信场景。

8

2026.01.15

公务员递补名单公布时间 公务员递补要求
公务员递补名单公布时间 公务员递补要求

公务员递补名单公布时间不固定,通常在面试前,由招录单位(如国家知识产权局、海关等)发布,依据是原入围考生放弃资格,会按笔试成绩从高到低递补,递补考生需按公告要求限时确认并提交材料,及时参加面试/体检等后续环节。要求核心是按招录单位公告及时响应、提交材料(确认书、资格复审材料)并准时参加面试。

44

2026.01.15

公务员调剂条件 2026调剂公告时间
公务员调剂条件 2026调剂公告时间

(一)符合拟调剂职位所要求的资格条件。 (二)公共科目笔试成绩同时达到拟调剂职位和原报考职位的合格分数线,且考试类别相同。 拟调剂职位设置了专业科目笔试条件的,专业科目笔试成绩还须同时达到合格分数线,且考试类别相同。 (三)未进入原报考职位面试人员名单。

58

2026.01.15

国考成绩查询入口 国考分数公布时间2026
国考成绩查询入口 国考分数公布时间2026

笔试成绩查询入口已开通,考生可登录国家公务员局中央机关及其直属机构2026年度考试录用公务员专题网站http://bm.scs.gov.cn/pp/gkweb/core/web/ui/business/examResult/written_result.html,查询笔试成绩和合格分数线,点击“笔试成绩查询”按钮,凭借身份证及准考证进行查询。

11

2026.01.15

Java 桌面应用开发(JavaFX 实战)
Java 桌面应用开发(JavaFX 实战)

本专题系统讲解 Java 在桌面应用开发领域的实战应用,重点围绕 JavaFX 框架,涵盖界面布局、控件使用、事件处理、FXML、样式美化(CSS)、多线程与UI响应优化,以及桌面应用的打包与发布。通过完整示例项目,帮助学习者掌握 使用 Java 构建现代化、跨平台桌面应用程序的核心能力。

65

2026.01.14

php与html混编教程大全
php与html混编教程大全

本专题整合了php和html混编相关教程,阅读专题下面的文章了解更多详细内容。

36

2026.01.13

PHP 高性能
PHP 高性能

本专题整合了PHP高性能相关教程大全,阅读专题下面的文章了解更多详细内容。

75

2026.01.13

MySQL数据库报错常见问题及解决方法大全
MySQL数据库报错常见问题及解决方法大全

本专题整合了MySQL数据库报错常见问题及解决方法,阅读专题下面的文章了解更多详细内容。

21

2026.01.13

PHP 文件上传
PHP 文件上传

本专题整合了PHP实现文件上传相关教程,阅读专题下面的文章了解更多详细内容。

35

2026.01.13

热门下载

更多
网站特效
/
网站源码
/
网站素材
/
前端模板

精品课程

更多
相关推荐
/
热门推荐
/
最新课程
最新Python教程 从入门到精通
最新Python教程 从入门到精通

共4课时 | 0.7万人学习

Django 教程
Django 教程

共28课时 | 3.1万人学习

SciPy 教程
SciPy 教程

共10课时 | 1.1万人学习

关于我们 免责申明 举报中心 意见反馈 讲师合作 广告合作 最新更新
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送

Copyright 2014-2026 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号