Python beginner's first day study notes-the first ptyhon program and python variable, pythonptyhon
1. python comments and the first python program:
1. Single line comment
# Author Xiajq
2. Multi-line comment
'''
------------ Comment content ---------------------------
'''
3. character encoding (not required for Versions later than python3.5. Utf8 is used by default)
-*-Coding: utf8 -*-
4. Run the command in a python File
#! /Usr/bin/python
5. The first python Program
#! /Usr/bin/ptyhon
#-*-Coding: utf8 -*-
# Author: XiaJinQi
Print ("hello wolrd ")
Ii. python variables:
1. python variables must consist of letters, underscores, and numbers. And cannot start with a number.
Name = "xiajinqi"
Print ("my name is {name}". format (name = name ))
Print ("my name is", name)
3. Format and output of strings.
Enter the user's basic information: name, age, job, and salary. And formatted and printed.
------------------------------------- Info of xiajiqni ----------------------------------
Name: xiajiqni
Age: 100
Salary: 33000.
Job: IT
1. Method 1:
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. method 2
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. Method 3
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 ")