hello world必备-》print函数


print():

作用:

打印函数,打印数据到屏幕中

参数列表:

print(value, ..., sep=' ', end='\n', file=sys.stdout, flush=False)

参数解释:

value,...,代表可以有多个要打印的数据,如print("a","b","c")
sep代表打印出的各个数据之间的参数
end代表打印结束字符,如\n代表打印完换行,\t代表打印完缩进到下一位置
file代表输出流,sys.stdout代表标准输出流,sys.stderr代表标准错误流
flush代表是否立即刷新缓冲区

用法:

print("hello world!")
print(1,2,3,sep='\t')
print('a','b','c',sep='#')
print(1,end='\t')
print(2)

输出结果:

hello world!
1 2 3
a#b#c
1 2

 


input():

作用:

输入函数,获取用户输入

参数列表:

input("输入提示信息")

用法:

name=input("你的名字:")
age=input("你的年龄:")

输出结果:

 

如果要使用非明文可见模式,使用getpass模块下的getpass:

(此模块在pycharm中无法正常使用))

用法:

import getpass
pwd=getpass.getpass("请输入密码:")

1.print()与input()的更多相关文章

  1. Learning Python 002 print() 和 input()

    Python print() 和 input() print()函数 print()函数可以向终端中输入指定的内容. 输出当个字符串 .py文件中,输入下面的代码,并保存: print('hello ...

  2. python3.5在print和input上的几个变化

    1. 在python3.5中使用print,打印内容必须用括号()括起来.python2.7中可以不用括号,如果你加了括号,代码在python2.7中也是可以正常运行的. python3.5 exam ...

  3. python中print和input的底层实现

    print print的底层通过sys.stdout.write() 实现 import sys print('hello') print('world') print(520) sys.stdout ...

  4. Python中的print、input函数以及Python中交换两个变量解析

    一.Python中的值交换操作 首先明确一点点,Python中的一切都是面向对象的,可以理解为Python的中一切都是对象. 我们知道Java也是面向对象的语言,但是在Java中定义一个值变量如下: ...

  5. 浅析 python中的 print 和 input 的底层区别!!!

    近期的项目中 涉及到相关知识 就来总结一下 ! 先看源码: def print(self, *args, sep=' ', end='\n', file=None): # known special ...

  6. [Python] Print input and output in table

    Print the input and output in a table using prettyTable. from prettytable import PrettyTable import ...

  7. 2.1 Python3基础-内置函数(print&input)

    >>返回主目录 源代码 # 内置函数:输入/输出 name = 'Portos' age = 18 sex = 'man' score = 99.5 print('Hello World! ...

  8. Python input 使用

    Python 3.0 中使用"input" , Python 2.0 中使用"raw_input"Python 3.5: #!C:\Program Files\ ...

  9. python学习03——设计,与input有关

    笨办法学python第36节,我写的代码如下: from sys import exit def rule(): print "Congratulations! You made the r ...

随机推荐

  1. 【Canal源码分析】重要类图

    从Canal的整体架构中,我们可以看出,在Canal中,比较重要的一些领域有Parser.Sink.Store.MetaManager.CanalServer.CanalInstance.CanalC ...

  2. Python之Pyautogui模块20180125《PYTHON快速上手让繁琐的工作自动化》18章

    复习 PyAutoGUI 的函数本章介绍了许多不同函数,下面是快速的汇总参考:moveTo(x,y)将鼠标移动到指定的 x.y 坐标.moveRel (xOffset,yOffset)相对于当前位置移 ...

  3. Installation failed with message...It is possible that this issue is resolved by uninstalling an existing version of the apk if it is present, and then re-installing.

    错误弹窗如图: Installation failed with message Failed to finalize session: INSTALL_FAILED_TEST_ONLY:instal ...

  4. 使用Java客户端对Redis进行操作

    一.背景 上篇文章我们介绍了如何在centos7下面进行安装单机版redis以及redis集群.这篇文章,我们来聊一聊如何使用java客户端来进行操作redis.我们知道redis的java客户端有很 ...

  5. 面试题----gcc的编译流程

    gcc编译流程 一.    编译与处理指令: gcc -E hello.c -o a.c 如果不使用-o指定输出的文件,会默认输出到终端.所以建议使用同时使用-o选项. 还要注意:编译时会保留#pra ...

  6. 我的MQ笔记

    1.安装IBM MQ 1.1.安装先决条件: (1)WebSphere  Eclipse  Platform  V3.01 (2)为Windows域用户配置WebSphere MQ用户 1.2.安装程 ...

  7. Go常量与运算符

    常量的定义 常量的值在编译时就已经确定 常量的定义格式与变量基本相同 等号右侧必须是常量或者常量表达式 常量表达式中的函数必须是内置函数 package main import ( "fmt ...

  8. Spring 环境与profile(一)——超简用例

    什么是profile,为什么需要profile? 在开发时,不同环境(开发.联调.预发.正式等)所需的配置不同导致,如果每改变一个环境就更改配置不但麻烦(修改代码.重新构建)而且容易出错.Spring ...

  9. es6学习笔记1

    最近在阅读<探索es6>,就把自己认为重要的做一点笔记,方便日后学习. 1.获取更多的es6资源的办法 有两组 ES6 资源: “ ECMAScript 6 Tools ”,作者 Addy ...

  10. core Animation之CATransition(转场动画)

    用于做转场动画,能够为层提供移出屏幕和移入屏幕的动画效果.iOS比Mac OS X的转场动画效果少一点 UINavigationController就是通过CATransition实现了将控制器的视图 ...