《笨办法学python》加分习题10——我的答案
来源:互联网 发布:java干货知识点分享 编辑:程序博客网 时间:2024/05/22 12:50
大家多指点,多指点!
原文练习:
tabby_cat = "\tI'm tabbed in."persian_cat = "I'm split\non a line."backslash_cat = "I'm \\ a \\ cat."fat_cat = """I'll do a list:\t* Cat food\t* Fishies\t* Catnip\n\t* Grass"""print tabby_catprint persian_catprint backslash_catprint fat_cat
今天这个就是用了转义符。
正文
1、
感谢AllenW的无私奉献,这里是该网页的地址:http://www.cnblogs.com/allenblogs/archive/2011/04/28/2031477.html非常感谢!
2、
附上代码截图:
结果截图:
提示说语法错误。
在之后编辑中发现是我的变量名错误。
附上修改的代码:
try5 = '''to do itand'''print try5
附上结果截图:
所以说三个单引号的功能和三个双引号的功能应该是一样的。就是打印其内部的所有东西吧。
3、
代码:
try_test = "there're\n try1:\n%s \nand\n try2:\n%r"try1_insert = "try!\nhahaha ,it's OK "try2_insert = "try!\nhahaha ,it's OK "print try_test % (try1_insert,try2_insert)
结果:
如上,可以看出%s和%r的区别很明显。正如作者所言,%s是我想要打印的东西,而%r是全部都打印上去。
阅读全文
0 0
- 《笨办法学python》加分习题10——我的答案
- 《笨办法学python》加分习题1——我的答案
- 《笨办法学python》加分习题2——我的答案
- 《笨办法学python》加分习题3——我的答案
- 《笨办法学python》加分习题4——我的答案
- 《笨办法学python》加分习题5——我的答案
- 《笨办法学python》加分习题6——我的答案
- 《笨办法学python》加分习题7——我的答案
- 《笨办法学python》加分习题8——我的答案
- 《笨办法学python》加分习题9——我的答案
- 《笨办法学python》加分习题11——我的答案
- 《笨办法学python》加分习题12——我的答案
- 《笨办法学python》加分习题13——我的答案
- 《笨办法学python》加分习题14——我的答案
- 《笨办法学python》加分习题15——我的答案
- 《笨办法学python》加分习题16——我的答案
- 《笨办法学python》加分习题17——我的答案
- 《笨办法学python》加分习题18——我的答案
- sckit-learn
- spring boot拦截器HandlerInterceptor详解
- 阿里巴巴编程规范之编程规约
- Windows下安装Redis
- 为什么写博客
- 《笨办法学python》加分习题10——我的答案
- 数组选择排序代码
- js 中的this
- MYSQL中的主健、普通索引、唯一索引和全文索引
- Uva 10110
- [入门]N!中1的位置
- CListCtrl控件使用
- Maven项目开发____Java工程项目Pom的依赖
- Phonenix4.9 (添加二级索引,新版本本地索引表变更) hbase1.25的集成测试