One, the Python comment and the first Python program:
1. Single-line Comment
# Author XIAJQ
2, multi-line Comment
‘‘‘
------------Comment Content---------------------------
‘‘‘
3, character encoding (python3.5 later version does not need to be set.) Use UTF8 by default)
-*-Coding:utf8-*-
4. Execute in Python file
#!/usr/bin/python
5. The first Python program
#!/usr/bin/ptyhon
# -*-Coding:utf8-*-
#Author: Xiajinqi
Print ("Hello wolrd")
Two, Python variables:
1, the Python variable must be a letter, underscore, the number composition. And start not a bit number.
Name = "Xiajinqi"
Print ("My name is {name}". Format (name =name))
Print ("My name is", name)
Three, the format of the string output of three ways.
Enter the user's basic information: name, age, job, salary. and format printing.
-------------------------------------Info of Xiajiqni----------------------------------
Name:xiajiqni
age:100
salary:33000
Job:it
1. Method One:
Name = input ("Name:")
Age = Input ("Age")
Salary = input ("salary")
Job = input ("job")
info = ""
--------------------------------------------------------------Info of%s---------------------------------------- -----------
Name:%s
Age:%s
Salary:%s
Job:%s
"% (Name,name,age,salary,job)
Print (info)
2, Mode two
Name = input ("Name:")
Age = Input ("Age:")
Salary = input ("Salary:")
Job = input ("Job:")
info = ""
--------------------------------------------------------------info of {name}------------------------------------ ---------------
Name: {Name}
Age: {Age}
Salary: {Salary}
Job: {Job}
". Format (Name=name,age=age,salary=salary,job=job)
Print (info)
3, Mode three
Name = input ("Name:")
Age = Input ("Age:")
Salary = input ("Salary:")
Job = input ("Job:")
info = ""
--------------------------------------------------------------info of {0}--------------------------------------- ------------
Name: {1}
Age: {2}
Salary: {3}
Job: {4}
". Format (Name,age,salary,job)
Print (info)
4. String concatenation (not recommended)
Print ("Age" + "100")
Novice Python first day of study notes-first Ptyhon program and Python variables