# python3

# 基本输入输出

#学会使用split()的使用是关键,input()的返回值一定是字符类型

.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-

 # Example Input
# 1 5
# Example Output
# a = []
for x in input().split():
a.append(int(x))
print(sum(a))

直接一行输出

 print(sum(int(x) for x in input().split()))

.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-

  # Example Input
# 1 5
# 10 20
# Example Output
#
# while True:
line = input()
if line:
print(sum(int(x) for x in line.split()))
else:
break

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-

  # Example Input
#
# 1 5
# 10 20
# Example Output
#
# N = int(input())
while(N):
print(sum(int(x) for x in input().split()))
N -= 1

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-

 # Example Input
# 1 5
# 10 20
# 0 0
# Example Output
#
# while True:
a = []
for x in input().split():
a.append(int(x))
if a[0] == a[1] == 0: # 以0 0结束
break
print(sum(a))

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-

 # Example Input
# 4 1 2 3 4
# 5 1 2 3 4 5
#
# Example Output
#
# while True:
a = []
line = input()
for x in line.split():
a.append(int(x))
if a[0] == 0:
break
print(sum(a)-a[0])

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-

 # Example Input
#
# 1 2 3 4
#
# 1 2 3 4 5
#
# Example Output
#
# while(int(input())):
print(sum(int(x) for x in input().split()))

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-

 # Example Input
#
# 4 1 2 3 4
# 5 1 2 3 4 5
# Example Output
#
# N = int(input())
while N:
a = []
line = input()
for x in line.split():
a.append(int(x))
print(sum(a)-a[0])
N -= 1

这些基础部分输入输出仅供参考、欢迎交流

Python3的一些基本输入输出的更多相关文章

  1. 【python3之变量,输入输出,判断,循环】

    一.python的基础语法和规则 1.变量 ①.变量的命名规则 语法: (下划线或字母)+(任意数目的字母.数字或下划线) 变量名必须以下划线或字母开头,而后面接任意数目的字母.数字或下划线.下划线分 ...

  2. py学习日记

    From:<python编程从入门到实践> 持续更新中... 都在代码里了 第一到七章: """ Author:CruelKing Time:7/27/201 ...

  3. input()和print()函数同时输入输出多个数据--python3

    使用input()和print()函数同时输入输出多个数据,需要空格分割输入信息 #!/usr/bin/python3#-*- conding:utf-8 -*- name, age, QQ = in ...

  4. python系列十三:Python3 输入输出

    #!/usr/bin/python #Python3 输入输出 import math'''输出格式美化Python两种输出值的方式: 表达式语句和 print() 函数.第三种方式是使用文件对象的 ...

  5. Python3简单的输入输出及内置函数查看

    工作之余和女朋友一起学Python3,代码都是她敲的,有点辣眼睛,仅做参考. 1.题目:输入"姓名",输出"你好,姓名" 有关安装和打开Python shell ...

  6. python2和python3输入输出相关

    python3: #coding=utf-8 a = input("请输入你的名字:") print("%s"%a) #输出没有一点问题,a就是字符串(或者数字 ...

  7. Python3中的输入输出

    input()函数 我们可以通过Python3解释器查看Python3中input()的含义: >>> type(input) <class 'builtin_function ...

  8. python课程:python3的输入输出

    输出函数用法 (话说python3的输出好像没有python2的灵活了) print('hello,world')   #单引号和双引号都可以输出print("hello,world&quo ...

  9. Python3.7.4入门-5输入输出

    5 输入输出 5.1 格式化字符串字面值 在字符串的开始引号或三引号之前加上一个 f 或 F .在此字符串中,你可以在 { 和 } 字符之间写可以引用的变量或字面值的 Python 表达式. > ...

随机推荐

  1. leetcode1028 从先序遍历还原二叉树 python 100%内存 一次遍历

    1028. 从先序遍历还原二叉树 python 100%内存 一次遍历     题目 我们从二叉树的根节点 root 开始进行深度优先搜索. 在遍历中的每个节点处,我们输出 D 条短划线(其中 D 是 ...

  2. django 中间键 csrf 跨站请求伪造

    django中间件和auth模块   Django中间件 由django的生命周期图我们可以看出,django的中间件就类似于django的保安,请求一个相应时要先通过中间件才能到达django后端( ...

  3. python 模块 来了 (调包侠 修炼手册一)

    模块 什么是模块 模块:就是一系列功能的结合体 ,也可以说 一个.py文件包含了 Python 对象定义和Python语 那么 他就 可以说是 一个模块 模块的三种来源: 1.内置的(python解释 ...

  4. Maven搭建Spring MVC

    Maven搭建SpringMVC 点击Enable Auto Import 下面配置文件 配置两个文件 web.app-->Web-INF--web.xml <!DOCTYPE web-a ...

  5. js语法基础入门(7)

    7.数组 7.1.什么是数组以及相关概念? 什么是数组?是一组数据有序排列的集合.将一组数据按一定顺序组织为一个组合,并对这个组合命名,这样便构成了数组. 什么是数组元素?组成数组的每一个数据称为数组 ...

  6. 【总结】LINQ查询基本操作列表

    每个LINQ查询都以from子句开始,from子句包括以下两个功能. 指定查询将采用数据源. 定义一个本地变量,表示数据源中单个元素. string[] values = { "中国&quo ...

  7. C# 9.0 新特性之 Lambda 弃元参数

    阅读本文大概需要不到 1 分钟. 弃元(Discards) 是在 C# 7.0 的时候开始支持的,它是一种人为丢弃不使用的临时虚拟变量.语法上它是用来赋值的,但它却不被分配存储空间,即没有值,所以不能 ...

  8. python之浅谈循环

    目录 流程控制之while循环 语法 while+break while+continue while+else while循环的嵌套 流程控制之for循环 语法 for+break for+cont ...

  9. Centos7安装docker与docker-compose

    Docker是一个开源的容器虚拟化平台 , Docker Compose是一个用来定义和运行复杂应用的Docker工具.使用Compose,你可以在一个文件中定义一个多容器应用,然后使用一条命令来启动 ...

  10. swaager-ui 美化版

    简介 Swagger UI允许任何人(无论您是开发团队还是用户)都可以可视化API资源并与之交互,而无需任何实现逻辑.它是根据您的OpenAPI(以前称为Swagger)规范自动生成的,具有可视化文档 ...