Three Python user interaction program

Source: Internet
Author: User

One: User input

Input ("")

Output input One:

%s: string

%d: Integral type

%f: Character type, decimal

% (variable 1, variable 2 ...)

Info1= ""
----------Info1 of%s-------------
name:%s
age:%d
job:%s
salary:%s
"% (name,name,age,job,salary)

Print (INFO1)

Input and output two:

{}. Format

Name:{_name}
Age:{_age}
Job:{_job}
Salary:{_salary}
". Format (
_name=name,
_age=age,
_job=job,
_salary=salary
)

Print (Info2)


Input mode Three
[]. Format
Info3= ""
----------Info3 of {0}-------------
Name:{1}
AGE:{2}
JOB:{3}
SALARY:{4}
". Format (name,name,age,job,salary)

Print (INFO3)

Summarize:

1%

2 {}.format

3 []. Fromat

4 Ciphertext acquisition

Import Getpass #先导入库

Password = getpass.getpass ("Password:")

Not available in Pycharm, can be used in IDE mode

Three Python user interaction program

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.