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 表达式. > ...
随机推荐
- 服务扫描-dmitry、nmap、amap和服务识别
dmitry使用-pb参数可以进行常用端口的banner抓取. 抓取效果: 强大的nmap也可以进行banner抓取,但是需要使用nmap内置的banner.nse脚本: kali中还有一个工具叫am ...
- ThinkPHP5使用阿里云OSS图片上传
1.下载OSS文件放在网站根目录下(OSS文件下载地址:https://gitee.com/jth1234/oss_files.git) 2.在入口文件中加载OSS 3.config文件配置oss信息 ...
- Idea中SpringBoot整合JSP
最近在学习SpringBoot,看到SpringBoot整合jsp,顺带记录一下. 1.创建一个SpringBoot项目 点击Next 注意:packaging选中War,点击Next Webà选中W ...
- Python 简明教程 --- 12,Python 字典
微信公众号:码农充电站pro 个人主页:https://codeshellme.github.io 代码写的越急,程序跑得越慢. -- Roy Carlson 目录 Python 字典是另一种非常实用 ...
- 《HelloGitHub》第 51 期
兴趣是最好的老师,HelloGitHub 就是帮你找到兴趣! 简介 分享 GitHub 上有趣.入门级的开源项目. 这是一个面向编程新手.热爱编程.对开源社区感兴趣 人群的月刊,月刊的内容包括:各种编 ...
- js基础练习题(3)
8.this 1.举例说说apply方法和call方法的作用和区别 2.读下面代码,写程序结果 function identify () { return this.name.toUpperCase( ...
- 使用onload和setTimeout、setInterval来实现当前的时间
1.在body里面使用onload和在函数中使用setTimeout来实现当前的日期时间不断变化 2.在script中直接是用setInterval实现当前实现的日期时间不断变化 <!DOCTY ...
- POJ 3463 Sightseeing 【最短路与次短路】
题目 Tour operator Your Personal Holiday organises guided bus trips across the Benelux. Every day the ...
- 如何用HMS Nearby Service给自己的APP开发一个名片交换功能?
在工作和生活中,遇见新的同事或者合作伙伴,交换名片是一个常见的用户需求,纸质名片常忘带.易丢失,是客户的一个痛点.因此,市场上出现了很多交换电子名片的APP和小程序.那么,如何给自己的APP开发一 ...
- \\u4e00-\\u9fa5\
select * from stu where name regexp '[\\u4e00-\\u9fa5\·]{2,10}$'; 结果: name这个字段从后到前 2 到10个字符之内 如果有汉字 ...