
python
NeoFive
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
python learning notes 1
---------------python_introduction.py----------------- #!/usr/bin/env python3 #variables and arithmetic expressions principal = 1000 rate = 0.05 numyears = 5 year = 1 while year <= numyea...原创 2019-05-08 23:47:42 · 221 阅读 · 0 评论 -
python的生成器与协程
使用yield语句,可以让函数生成一个结果序列,而不仅仅是一个值 #!/usr/bin/env python3 def countdown(n): print("Counting down", end = " ") while n > 0: yield n n -= 1 c = countdown(5) for i in range(4): print(c.__next...原创 2019-05-23 23:30:52 · 204 阅读 · 0 评论 -
python中seek函数的使用
1、seek函数 file.seek(off, whence=0):从文件中移动off个操作标记(文件指针),正往结束方向移动,负往开始方向移动。如果设定了whence参数,就以whence设定的起始位为准,0代表从头开始,1代表当前位置,2代表文件最末尾位置。 2.例子 #!/usr/bin/env python3 from sys import argv #arg[0] is seek...原创 2019-05-23 23:34:19 · 7154 阅读 · 0 评论 -
python的list基本操作
#!/usr/bin/python3 import sys if len(sys.argv) != 2: print("please input a filename") raise SystemExit(1) f = open(sys.argv[1]) lines = f.readlines() #read all line. print(lines) #line = f.readl...原创 2019-05-23 23:38:08 · 170 阅读 · 0 评论 -
python的tuple基本操作
#!/usr/bin/env python3 item = "hello" a = () print(a) b = (item,) print(b) b = (item) print(b) c = item, print(c) c = item print(c) # () # ('hello',) # hello # ('hello',) # hello sock = ('good'...原创 2019-05-23 23:40:17 · 271 阅读 · 0 评论 -
python中类的基本使用
#!/usr/bin/env python3 class Stack(object): def __init__(self): self.stack = [] def push(self, object): self.stack.append(object) def pop(self): return self.stack.pop() def length(self): ...原创 2019-05-23 23:44:18 · 493 阅读 · 1 评论 -
python中的dict基本操作
#!/usr/bin/env python3 #define s = set([1,2,3]) print(s) t = set("hello") print(t) a = s | t b = s & t c = s - t d = s ^ t print(a, b, c, d) t.add('x') print(t) s.update([10, 11, 12]) #repl...原创 2019-05-23 23:49:31 · 275 阅读 · 0 评论