Python3的一些基本输入输出
# 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的一些基本输入输出的更多相关文章
- 【python3之变量,输入输出,判断,循环】
一.python的基础语法和规则 1.变量 ①.变量的命名规则 语法: (下划线或字母)+(任意数目的字母.数字或下划线) 变量名必须以下划线或字母开头,而后面接任意数目的字母.数字或下划线.下划线分 ...
- py学习日记
From:<python编程从入门到实践> 持续更新中... 都在代码里了 第一到七章: """ Author:CruelKing Time:7/27/201 ...
- input()和print()函数同时输入输出多个数据--python3
使用input()和print()函数同时输入输出多个数据,需要空格分割输入信息 #!/usr/bin/python3#-*- conding:utf-8 -*- name, age, QQ = in ...
- python系列十三:Python3 输入输出
#!/usr/bin/python #Python3 输入输出 import math'''输出格式美化Python两种输出值的方式: 表达式语句和 print() 函数.第三种方式是使用文件对象的 ...
- Python3简单的输入输出及内置函数查看
工作之余和女朋友一起学Python3,代码都是她敲的,有点辣眼睛,仅做参考. 1.题目:输入"姓名",输出"你好,姓名" 有关安装和打开Python shell ...
- python2和python3输入输出相关
python3: #coding=utf-8 a = input("请输入你的名字:") print("%s"%a) #输出没有一点问题,a就是字符串(或者数字 ...
- Python3中的输入输出
input()函数 我们可以通过Python3解释器查看Python3中input()的含义: >>> type(input) <class 'builtin_function ...
- python课程:python3的输入输出
输出函数用法 (话说python3的输出好像没有python2的灵活了) print('hello,world') #单引号和双引号都可以输出print("hello,world&quo ...
- Python3.7.4入门-5输入输出
5 输入输出 5.1 格式化字符串字面值 在字符串的开始引号或三引号之前加上一个 f 或 F .在此字符串中,你可以在 { 和 } 字符之间写可以引用的变量或字面值的 Python 表达式. > ...
随机推荐
- 阿里druid数据源属性配置表
https://cloud.tencent.com/developer/article/1368903 DRUID 属性说明表 属性(Parameter) 默认值(Default) 描述(Descri ...
- 【服务器】CentOs7系统使用宝塔面板搭建网站,有FTP配置(保姆式教程)
内容繁多,请耐心跟着流程走,在过程中遇到问题请在下面留言(我只是小白,请专业人士喷轻点). 这次用thinkphp5.1做演示,单纯的做演示,我打算下一篇文章用typecho(博客框架)演示. 前言 ...
- mock api测试demo
前言 本测试demo基于Spring框架测试,这几个月也是刚刚接触Spring的项目.如果不对的地方请多谅解. 正文 1.创建测试类,添加注解 @RunWith(SpringRunner.class) ...
- 并发02--JAVA内存模型
在并发编程中,需要解决两个问题:线程间如何通信&线程间如何同步 线程同步:控制不同线程操作顺序的机制 解决这两个问题的方案有两种:共享内存&消息传递 共享内存:通过使用共享内存,隐式通 ...
- webstorm 调试 typescript
{ "compilerOptions": { "target": "es5", "outFile": "bin ...
- P2194 HXY烧情侣【Tarjan】
前言 当时和\(GYZ\)大佬一起做这个题,他表示这个题对他很不友好(手动滑稽) 题目描述 众所周知,\(HXY\) 已经加入了 \(FFF\) 团.现在她要开始喜(sang)闻(xin)乐(bing ...
- Spring中使用注解时启用<context:component-scan/>
在spring中使用注解方式时需要在spring配置文件中配置组件扫描器:http://blog.csdn.net/j080624/article/details/56277315 <conte ...
- 《算法笔记》6.7小节 问题 A: 简单计算器
又是大模拟淦淦淦淦淦淦淦 思路: 这道题我居然用的队列orz. 言归正传,这道题就是模拟计算器.从读题目样例可以发现,数字的个数只比符号的个数多一个,那么这就给我们了思路:用队列,先提前放出一个数,每 ...
- SpringBoot-读取classpath下文件
文章目录 开发过程中,必不可少的需要读取文件,对于打包方式的不同,还会存在一些坑,比如以jar包方式部署时,文件都存在于jar包中,某些读取方式在开发工程中都可行,但是打包后,由于文件被保存在jar中 ...
- docker 容器中 apt-get install 软件时,提示无法定位软件包
[解决] 执行 apt-get update 然后再进行安装,即可. (完)