Python Learning (first article)

Source: Internet
Author: User

Description: The version used by the author is python3.6

First, let's talk about Python's three format output. The first one uses the format operator%, and when formatting the string, Python uses a string as the template. There are formatting characters in the template that reserve locations for real values and describe the format in which real values should be rendered.

Python uses a tuple (tuple) to pass multiple values to the template, each of which corresponds to a format character.

The second use of the Format method, please read the code carefully.

1 #Author:yang2Name=input ("Name:")3Age=input ("Age :")4Job=input ("Job:")5info=" "6 ----------Info of%s------------7 name:%s8 age:%s9 job:%sTen " "%(name,name,age,job) OneInfo2=" " A ---------Info of {0}----------- - name:{0} - Age:{1} the job:{2} - " ". Format (name,age,job) -info3=" " - ---------info of {na}----------- + Name:{na} - Age:{ag} + JOB:{JB} A " ". Format (na=name,ag=age,jb=job) at Print(Info) - Print(Info2) - Print(INFO3)

Second, to say a different case of the assignment, see the following code:

Code (1)

a=[1,2,3]
B=a
A.append (4)
Print (a)
Print (b)
Code (2)
a=[1,2,3]
B=a
a=[4,5,6]
Print (a)
Print (b)

A list assignment is not a full copy, but a two variable pointing to the same piece of memory on the computer.

Python Learning (first article)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.