python3.5在print和input上的几个变化
1. 在python3.5中使用print,打印内容必须用括号()括起来。python2.7中可以不用括号,如果你加了括号,代码在python2.7中也是可以正常运行的。
python3.5 examples:
print("this is the format in python3.5") version="python3.5"
print("this is the format in",version)
print("this is the format in %s" %version) language="python"
version=3
print("this is the format in %s%d" % (language,version))
2. raw_input在python3.5中消失了,input方法取代了它。然而,如果你是在python2.7中使用input方法,其效果跟python3.5中完全不同。python2.7中的input方法,只能接受变量作为传入值,否则会报错,如下:
python2.7中使用input时的正确做法:(不看也罢,反正3.5开始就没这回事了)
补充,在python3.5中格式化字符串。用三引号将排版好的字符串引起来即可,三引号可以是3个单引号,也可以是3个双引号。
name =input("input your name:")
age =input("input your age:")
job =input("input your job:") msg = '''
Information of user %s:
-------------------------
name:%s
age:%d
job:%s
------------End----------
''' % (name,name,age,job) print(msg)
python3.5在print和input上的几个变化的更多相关文章
- python3入门之print,import,input介绍
本节主要介绍print,import和input,t函数,包括他们在python2.7和python3 的区别以及用法.下面附有之前的文章: python3的print函数的变化 python3之 ...
- Python3.7.2,在Linux上跑来跑去的,是在升级打怪么?
Python3.7.2,在Linux上跑来跑去的,是在升级打怪么? 前不久,发布了Python在Windows(程序员:Python学不学?完全没必要纠结)和Mac OS(我是Python,P派第 ...
- Python3.x:如何识别图片上的文字
Python3.x:如何识别图片上的文字 安装pytesseract库,必须先安装其依赖的PIL及tesseract-ocr,其中PIL为图像处理库,而后面的tesseract-ocr则为google ...
- Learning Python 002 print() 和 input()
Python print() 和 input() print()函数 print()函数可以向终端中输入指定的内容. 输出当个字符串 .py文件中,输入下面的代码,并保存: print('hello ...
- input上传按钮美化
<!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content ...
- css input[type=file] 样式美化,input上传按钮美化
css input[type=file] 样式美化,input上传按钮美化 参考:http://www.haorooms.com/post/css_input_uploadmh
- 使用jquer获取当前时间,并赋值到input上。
今天,做一个项目,需要将自动获取的时间能够赋值到input上.我一开始试用javascript写的,写之后使用很多办法都赋值失败,最后使用了jquery写了出来,下面附上代码. <script ...
- Python3实现ICMP远控后门(上)_补充篇
ICMP后门(上)补充篇 前言 在上一篇文章Python3实现ICMP远控后门(上)中,我简要讲解了ICMP协议,以及实现了一个简单的ping功能,在文章发表之后,后台很多朋友留言,说对校验和的计算不 ...
- input上传限定文件类型
input上传限定文件类型 accept="image/*" 限定为只能上传图片 accept=”audio/* 限定为只能上传音频 accept=”video/*” 限定 ...
随机推荐
- android listView Exception
- ::-/com.tongyan.tutelage W/System.err﹕ java.text.ParseException: Unparseable date: ) - ::-/com.ton ...
- jsPlumb
官网:https://jsplumbtoolkit.com GitHub:https://github.com/sporritt/jsplumb/ 初始化 jsPlumb只有等到DOM初始化完成之后才 ...
- FileSystemWatcher
转:http://www.cnblogs.com/zhaojingjing/archive/2011/01/21/1941586.html 注意:用FileWatcher的Created监控文件时,是 ...
- myBatis出现Mapped Statements collection already contains value for
造成这个问题的原因很多,我遇到的主要是因为 <select id="queryCountfor****" parameterType="java.lang.Inte ...
- php 获取时间今天明天昨天时间戳
<?php echo "今天:".date("Y-m-d")."<br>"; echo "昨天:&qu ...
- JqGrid单选
You have to do some more stuff: 1. Set multiboxonly to true and multiselect to true 2. Define the ev ...
- 字典查找、linq、foreach、yield等几种查找性能对比
先上代码,以1千万记录的内存查找测试: List<Student> stuList = new List<Student>(); Dictionary<int, Stud ...
- Using Redis as Django's session store and cache backend
http://michal.karzynski.pl/blog/2013/07/14/using-redis-as-django-session-store-and-cache-backend/
- SELinux配置不当导致vsftpd系统用户不能登陆
1.测试是否是SELinux配置不当导致的: setenforce 0 再次登陆ftp,正常,说明是SELinux配置不当导致.还原配置 setenforce 1 2.查看配置: getsebool ...
- [转]使用 HttpClient 和 HtmlParser 实现简易爬虫
http://www.ibm.com/developerworks/cn/opensource/os-cn-crawler/ http://blog.csdn.net/dancen/article/d ...