Python中的输入和输出

输入

input()

 

#!/usr/bin/env python
#-*- coding:utf-8 -*-

username=input('请输入用户名: ')

input()内置函数,返回字符串类型。如果输入的内容要作为其他类型使用,必须进行转换,如要转换为int,就要 int(要转换的标识符)。

输出 print()

格式化输出

username='admin'
password='123456'

print('用户名为 %s ,密码为 %s' %(username,password))

%d整数   %f 浮点数   

常用的格式化:

原文地址:https://www.cnblogs.com/PythonInMyLife/p/6919012.html