Python basics

Variables and types

a=1 #Variable a is an integer
t007='T007” #Variable t007 is a string
  1. Create a string of'ABC' in memory
  2. Create a variable named a in memory and point it to'ABC'

Identifiers and keywords##

Python some identifiers with special functions, these are the so-called keywords
The keyword is already used by python, so developers are not allowed to define the identifier with the same name as the keyword.

>>> import keyword #First introduce the keyword package
>>> keyword.kwlist #View keywords
and     as      assert    breakclasscontinue    def     del
elif    else    except    exec    finallyforfrom    global
ifinimport    is      lambda     not         or      pass
print   raise   returntrywhilewithyield

Output##

# Normal output
a=10print("This is the variable",a)

# Formatted output
age=20
name="Xiao Zhang"print("His age is%d years old"%age)print("his name is%s, nationality is%s"%(name,"China"))

operation result

Other output formats##

print("aaa","bbb","ccc")print("www","baidu","com",sep=".")

result:

print("hello",end="") #No line break
print("world",end="\t") #A tab before the next output
print("python",end="\n") #Wrap
print("end")

result:

enter##

password =input("Please enter password:") #keyboard input
print("The password you just entered is:",password)print("The types of numbers entered by the keyboard are:",type(password)) #The keyboard input is a string type

password_2 =int(password) #Cast to int type
print("The type after coercion is:",type(password_2))

result:

Recommended Posts

Python basics
Python basics
Python basics 3
Python basics 4
Python basics 5
Python object-oriented basics
Python custom function basics
Basics of Python syntax
Python multi-process and multi-thread basics
Python multithreading
Python CookBook
Python FAQ
Python3 dictionary
Python3 module
python (you-get)
Python string
Python descriptor
Python exec
Python notes
CentOS + Python3.6+
Python advanced (1)
Python decorator
Python IO
Python multithreading
Python3 list
Python multitasking-coroutine
python introduction
07. Python3 functions
Python multitasking-threads
Python functions
python sys.stdout
python operator
Python entry-3
Centos 7.5 python3.6
Python string
python queue Queue
Learn the basics of python interactive mode
Centos6 install Python2.7.13
Python answers questions
Python basic syntax (1)
Centos7 install Python 3.6.
ubuntu18.04 install python2
Python classic algorithm
Relearn ubuntu --python3
Python2.7 [Installation Tutorial]
Python string manipulation
Python 3.9 is here!
Python study notes (1)
python learning route
CentOS7 upgrade python3
Python3 basic syntax
linux+ubuntu solve python
Functions in python
Python learning-variable types
CentOS install Python 3.6
7 features of Python3.9
Python file operation
ubuntu12.04 install python3
Python design patterns
Python - centos6 installation
Centos7 install Python2.7