Python
sangyuping
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
欢迎使用优快云-markdown编辑器
欢迎使用Markdown编辑器写博客本Markdown编辑器使用StackEdit修改而来,用它写博客,将会带来全新的体验哦:Markdown和扩展Markdown简洁的语法代码块高亮图片链接和图片上传LaTex数学公式UML序列图和流程图离线写博客导入导出Markdown文件丰富的快捷键快捷键加粗 Ctrl + B 斜体 Ctrl + I 引用 Ctrl原创 2015-10-09 15:02:12 · 228 阅读 · 0 评论 -
python模块--random
学习收藏了下关于Python中的random模块相关的知识:如果你已经了解伪随机数(psudo-random number)的原理,那么你可以使用如下:random.seed(x)来改变随机数生成器的种子seed。如果你不了解其原理,你不必特别去设定seed,Python会帮你选择seed。1) 随机挑选和排序random.choice(seq) # 从序列的元素中随机挑选一个元素,比如rand转载 2016-02-15 10:30:34 · 411 阅读 · 0 评论 -
Python之 with and as
The ‘with’ and ‘as’ Keywords Programming is all about getting the computer to do the work. Is there a way to get Python to automatically close our files for us?Of course there is. This is Python.You m原创 2016-01-26 16:28:21 · 478 阅读 · 0 评论 -
python 之 readline
What if we want to read from a file line by line, rather than pulling the entire file in at once. Thankfully, Python includes a readline() function that does exactly that.If you open a file and call .r原创 2016-01-26 15:56:47 · 554 阅读 · 0 评论 -
Python之I/O
my_list = [i**2 for i in range(1,11)]# Generates a list of squares of the numbers 1 - 10f = open("output.txt", "w") ##Open output.txt in w modefor item in my_list: f.write(str(item) + "\n")f.close原创 2016-01-26 15:35:55 · 535 阅读 · 0 评论 -
class 之 ___repr__
When defining a new repr(), return a string value that uses the member variables of the class to display the 3D point properly. You can use the str() function to put these numbers in the proper string.原创 2016-01-26 15:10:29 · 243 阅读 · 0 评论 -
python 之class (Overriding methods)
Overriding methods Since our ElectricCar is a more specialized type of Car, we can give the ElectricCar its own drive_car() method that has different functionality than the original Car class’s.题目: I原创 2016-01-25 18:02:27 · 754 阅读 · 0 评论 -
python 学习之---class (inheritance)
因为工作需要,一大把年纪还得开始学习python,哎,是在不容易,如何入手呢,根据牛人的经验,找本书看看,最基础的还是看了codecademy上的习题,内容简单,有提示,实在不行,还有google,还是挺好的,现在,只是想把一些自己的理解记录下来,以供自己日后借鉴:class:题目: Create a class ElectricCar that inherits from Car. Give y原创 2016-01-25 15:22:44 · 744 阅读 · 0 评论 -
文章标题
from math import sqrtdef sqrt (number): sqrts = sqrt(number) print sqrts转载 2015-11-23 16:51:02 · 207 阅读 · 0 评论 -
python 学习 (type)
type可以返回执行的类型eg:print type (42)print type ("42")转载 2015-11-23 16:42:28 · 205 阅读 · 0 评论 -
python每日学习---r
在python中,我们经常会在print中看到这样的格式:print r"hello\n"其实,这里的r就是禁止转义用的,所以,最终的输出结果是: hello\n 而print "hello\n" 则会输出的是 hello换行 这个经常会用在正则的地方,因为正则的时候经常需要使用到需要转义的地方 举个之前的例子:result_serch = re.search(r'custom\.sh['原创 2016-09-08 21:58:13 · 346 阅读 · 0 评论
分享