Python学习笔记【1】
来源:互联网 发布:three.js 实现宇宙 编辑:程序博客网 时间:2024/05/07 03:34
1、%r和%s的区别
(1)stackflow 上面的一个解答
(2)
x = "There are %d types of people." %10binary = "binary"do_not = "don't"y = "Those who know %s and those who %s." % (binary,do_not)print xprint yprint "I said: %r." % xprint "I also said: '%s'." % yprint "I also said: %s." %yprint "I also said: '%r'." %yprint "I also said: %r." %yhilarious = Falsejoke_evaluation = "Isn't that joke so funny?!%r"print joke_evaluation % hilariousw = "This is the left side of..."e = "a string with a right side."print w + e
2、Python 的规则里,只要一行以“冒号(colon)”: 结尾,它接下来的内容就应该有缩进。
3、可以直接将 elements 赋值为 range(0,6),而无需使用 for 循环
4、从命令行参数读入的数据都是字符串形式,如果需要按整数形式处理,则需要类型转换函数:int(counts)
5、使用函数时候,要注意函数内和函数外变量的作用范围(生命周期)
6、range函数的增加序列差值只能为1,要想改变循环增加的差值,可以用while-loop结构
7、判断字符从next是否为纯数字:
参考:Python判断字符串是否为纯数字
8、yield关键字用法
参考:Python yield浅析
- python学习笔记1
- python学习笔记(1)
- python学习笔记(1)
- Python学习笔记1
- Python学习笔记1
- Python 学习笔记(1)
- Python学习笔记1
- python学习笔记【1】
- Python学习笔记【1】
- python学习笔记--1
- python学习笔记1
- Python学习笔记[1]
- python学习笔记--1
- python学习笔记1
- Python学习笔记 - 1
- 学习Python笔记1
- Python学习笔记(1)
- Python学习笔记.1
- php如何安装PECL
- 获取当前设备语言
- struts的ajax请求
- 对于非负整数0,1,2,....n-1,随机放入一个大小为n的一维数组中,调整元素顺序,辅助空间为O(1)
- 百度 求矩形的个数
- Python学习笔记【1】
- Matlab 关于plot设置(暴力版)
- 查看Oracle当前用户下的信息(用户,表视图,索引,表空间,同义词,存储过程函数,约束条件)自_baidu
- netstat -nat | awk '/^tcp/{++S[$NF]}END{for (a in s) print a,S[a]}'详解
- C++编译器如何处理静态成员
- MySQLdb for Python使用指南/Python的数据库操作
- (一)android升级--升级包的制作
- python 连接MYSQL数据库(入门帖)
- Oracle用Start with...Connect By子句递归查询