Python is an interpreted language
Choice of python 2 or 3:
Python 2.7 is the latest and last version of 2, and the update supports Updates will stop in 2020, but companies that are currently using or have developed it continue to use python2, so the transition period for updates still has a way to go, and python 3 will be the long-term development in the future. A better choice (this is only for beginners), of course, when learning python3, you must understand the different features between 2 and 3.
Installation and configurationwindows
##1. Download the installation package
/
/
www.python.org
/
downloads
/
2
3
-
-
》[Properties]
-
-
》[Advanced system settings]
-
-
》[Advanced]
-
-
》[Environment Variables]
-
-
》[Find the line with the variable name Path in the second content box, double-click it]
-
-
> [The Python installation directory is appended to the variable value, separated by;]
##linux, Mac
No installation required, original Python environment
ps: If you have
, please update to
2.7 or other versions
1 print 'Hello World!' #python2的写法2 print ('Hello World!') #python3的写法
name='Tom'
Variable names can only be any combination of letters, numbers or underscores
-
The first character of the variable name cannot be a number
-
The following keywords cannot be declared as variable names
['and', 'as', 'assert', ' break', 'class', 'continue', 'def', 'del', 'elif', 'else', 'except', 'exec', 'finally', 'for', 'from', 'global' , 'if', 'import', 'in', 'is', 'lambda', 'not', 'or', 'pass', 'print', 'raise', 'return', 'try', ' while', 'with', 'yield'] -
Assignment of variables
name= =name (name2)
should be displayed at the beginning of the file to tell the python interpreter what encoding to use to execute the source code, that is:
#!/usr/bin/env python# -*- coding: utf-8 -*- #告诉python字符编码 print "你好,世界"
注释
当行注视:# 被注释内容
多行注释:""" 被注释内容 """
数据类型初识
2 是一个整数的例子。
长整数 不过是大一些的整数。
3.23和52.3E-4是浮点数的例子。E标记表示10的幂。在这里,52.3E-4表示52.3 * 10-4。
(-5+4j)和(2.3-4.6j)是复数的例子,其中-5,4为实数,j为虚数,数学中表示复数是什么?。
int(整型)
在64位系统上,整数的位数为64位,取值范围为-2**63~2**63-1,即-9223372036854775808~9223372036854775807
跟C语言不同,Python的长整数没有指定位宽,即:Python没有限制长整数数值的大小,但实际上由于机器内存有限,我们使用的长整数数值不可能无限大。
注意,自从Python2.2起,如果整数发生溢出,Python会自动将整数数据转换为长整数,所以如今在长整数数据后面不加字母L也不会导致严重后果了。
float(浮点型)
浮点数用来处理实数,即带有小数的数字。类似于C语言中的double类型,占8个字节(64位),其中52位表示底,11位表示指数,剩下的一位表示符号。
complex(复数)
复数由实数部分和虚数部分组成,一般形式为x+yj,其中的x是复数的实数部分,y是复数的虚数部分,这里的x和y都是实数。
"hello world"
接收用户输入
#!/usr/bin/env python#_*_coding:utf-8_*_ #name = raw_input("请输入用户名") #只有 python 2.x有这种写法name=input('请输入用户名:')print('Hello '+name)
if else ...
#!/usr/bin/env python# -*- coding: encoding -*-age=int(input('请输入年龄:')) #接收一个age值,这里因为age是一个int类型,所以需要强制转换一下if age
if elif else ...
#!/usr/bin/env python# -*- coding: encoding -*-my_age=22 #定义一个自己的年龄age=int(input('请输入年龄')) #接收一个年龄if age==my_age:print('猜对了') #如果输入的值等于my_age的值 输出猜对了elif age<my_ageprint></my_ageprint>
while 循环 ...
#!/usr/bin/env python# -*- coding: encoding -*-count=0 #定义一个值为count的计数器while True: print(count) #如果为真就一直循环 这是一个死循环,不停止程序会一直执行count+=1 #循环一次给计数器+1
for 循环 ...
#!/usr/bin/env python# -*- coding: encoding -*-for i in range(10)print(i) #最简单的循环打印10次
The above is the detailed content of An interpreted language--an introduction to python. For more information, please follow other related articles on the PHP Chinese website!

本篇文章给大家带来了关于Python的相关知识,其中主要介绍了关于Seaborn的相关问题,包括了数据可视化处理的散点图、折线图、条形图等等内容,下面一起来看一下,希望对大家有帮助。

本篇文章给大家带来了关于Python的相关知识,其中主要介绍了关于进程池与进程锁的相关问题,包括进程池的创建模块,进程池函数等等内容,下面一起来看一下,希望对大家有帮助。

本篇文章给大家带来了关于Python的相关知识,其中主要介绍了关于简历筛选的相关问题,包括了定义 ReadDoc 类用以读取 word 文件以及定义 search_word 函数用以筛选的相关内容,下面一起来看一下,希望对大家有帮助。

本篇文章给大家带来了关于Python的相关知识,其中主要介绍了关于数据类型之字符串、数字的相关问题,下面一起来看一下,希望对大家有帮助。

VS Code的确是一款非常热门、有强大用户基础的一款开发工具。本文给大家介绍一下10款高效、好用的插件,能够让原本单薄的VS Code如虎添翼,开发效率顿时提升到一个新的阶段。

本篇文章给大家带来了关于Python的相关知识,其中主要介绍了关于numpy模块的相关问题,Numpy是Numerical Python extensions的缩写,字面意思是Python数值计算扩展,下面一起来看一下,希望对大家有帮助。

pythn的中文意思是巨蟒、蟒蛇。1989年圣诞节期间,Guido van Rossum在家闲的没事干,为了跟朋友庆祝圣诞节,决定发明一种全新的脚本语言。他很喜欢一个肥皂剧叫Monty Python,所以便把这门语言叫做python。


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Atom editor mac version download
The most popular open source editor

DVWA
Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

VSCode Windows 64-bit Download
A free and powerful IDE editor launched by Microsoft

SecLists
SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.