1
2
3
4
5
6
7
8
|
#!/usr/bin/env python #_*_coding:utf-8_*_ username =input("username:")
password = input("password:")
print(username,password)
|
上面一个是简单的输入,下面我们来一个复杂的:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
|
#!/usr/bin/env python # -*- coding: utf-8 -*- name = input("name")
age = input("age") or int(input("age"))
job = input("job")
salary = input("salary")
info = ‘‘‘
---------- info of %s ---------
Name:%s
Age:%s or %d
Job:%s
Salary:%s
‘‘‘ %(name,name,age,job,salary)
print(info)
|
ps:
%s 字符串
%d 整数
%f 浮点(小数)
下面一个.format 字符串的用法
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
#!/usr/bin/env python #_*_coding:utf-8_*_ name = input("name")
age = input("age")
job = input("job")
salary = input("salary")
info = ‘‘‘
---------- info of {_name} ---------
Name:{_name}
Age:{_age}
Job:{_job}
Salary:{_salary}
‘‘‘. format(_name=name,
_age=age,
_job=job,
_salary=salary)
print(info)
|