python print 按逗号或空格分隔的方法


Posted in Python onMay 02, 2018

1)按,分隔

a, b = 0, 1 
while b < 1000: 
 print(b, end=',') 
 a, b = b, a+b 
1,1,2,3,5,8,13,21,34,55,89,144,233,377,610,987,

2)按空格分隔

a, b = 0, 1 
while b < 1000: 
 print(b, end=' ') 
 a, b = b, a+b 

1 1 2 3 5 8 13 21 34 55 89 144 233 377 610 987

3)print的用法

print(...)
 print(value, ..., sep=' ', end='\n', file=sys.stdout, flush=False)
 
 Prints the values to a stream, or to sys.stdout by default.
 Optional keyword arguments:
 file: a file-like object (stream); defaults to the current sys.stdout.
 sep: string inserted between values, default a space.
 end: string appended after the last value, default a newline.
 flush: whether to forcibly flush the stream.

以上这篇python print 按逗号或空格分隔的方法就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持三水点靠木。

Python 相关文章推荐
python在windows下实现ping操作并接收返回信息的方法
Mar 20 Python
python实现DES加密解密方法实例详解
Jun 30 Python
python中nan与inf转为特定数字方法示例
May 11 Python
Django数据库操作的实例(增删改查)
Sep 04 Python
python3+PyQt5泛型委托详解
Apr 24 Python
python使用Matplotlib绘制分段函数
Sep 25 Python
python爬取淘宝商品销量信息
Nov 16 Python
Python面向对象之继承和多态用法分析
Jun 08 Python
使用Python做垃圾分类的原理及实例代码附源码
Jul 02 Python
python实现电子书翻页小程序
Jul 23 Python
python虚拟环境的安装和配置(virtualenv,virtualenvwrapper)
Aug 09 Python
tensorflow 实现自定义layer并添加到计算图中
Feb 04 Python
Django 跨域请求处理的示例代码
May 02 #Python
python 按照固定长度分割字符串的方法小结
Apr 30 #Python
Python 内置函数进制转换的用法(十进制转二进制、八进制、十六进制)
Apr 30 #Python
python版本的仿windows计划任务工具
Apr 30 #Python
Python装饰器原理与用法分析
Apr 30 #Python
Python中pillow知识点学习
Apr 30 #Python
Python生成器定义与简单用法实例分析
Apr 30 #Python
You might like
php禁止浏览器使用缓存页面的方法
2014/11/07 PHP
php使用pear_smtp发送邮件
2016/04/15 PHP
php多线程并发实现方法
2016/09/30 PHP
PHP curl 或 file_get_contents 获取需要授权页面的方法
2017/05/05 PHP
Windows上php5.6操作mongodb数据库示例【配置、连接、获取实例】
2019/02/13 PHP
thinkphp5框架实现的自定义扩展类操作示例
2019/05/16 PHP
php数组函数array_push()、array_pop()及array_shift()简单用法示例
2020/01/26 PHP
javascript 操作Word和Excel的实现代码
2009/10/26 Javascript
浅析JavaScript原型继承的陷阱
2013/12/03 Javascript
使用js画图之正弦曲线
2015/01/12 Javascript
牛叉的Jquery——Jquery与DOM对象的互相转换及DOM的三种操作
2015/10/29 Javascript
jQuery实现放大镜效果实例代码
2016/03/17 Javascript
JavaScript 经典实例日常收集整理(常用经典)
2016/03/30 Javascript
JS代码实现table数据分页效果
2016/05/26 Javascript
Angular实现的内置过滤器orderBy排序与模糊查询功能示例
2017/12/29 Javascript
使用 Vue 实现一个虚拟列表的方法
2019/08/20 Javascript
原生js无缝轮播插件使用详解
2020/03/09 Javascript
[03:23]我的刀塔你不可能这么可爱 第一期金萌萌的故事
2014/06/20 DOTA
python刷投票的脚本实现代码
2014/11/08 Python
python检测远程udp端口是否打开的方法
2015/03/14 Python
Python六大开源框架对比
2015/10/19 Python
python虚拟环境的安装配置图文教程
2017/10/20 Python
python2.7安装图文教程
2018/03/13 Python
Python用5行代码写一个自定义简单二维码
2018/10/21 Python
Python跳出多重循环的方法示例
2019/07/03 Python
使用Python获取当前工作目录和执行命令的位置
2020/03/09 Python
印度领先的在线时尚商店:Koovs
2016/08/28 全球购物
租租车:国际租车、美国租车、欧洲租车、特价预订国外租车(中文服务)
2018/03/28 全球购物
如何将无状态会话Bean发布为WEB服务,只有无状态会话Bean可以发布为WEB服务?
2015/12/03 面试题
法律专业自我鉴定
2013/10/03 职场文书
毕业生教师求职信
2013/10/20 职场文书
大一期末自我鉴定
2013/12/13 职场文书
财产保全担保书范文
2014/04/01 职场文书
优秀纪检干部材料
2014/08/27 职场文书
Java GUI编程菜单组件实例详解
2022/04/07 Java/Android
使用MybatisPlus打印sql语句
2022/04/22 SQL Server