
python
坚持到底cw
奋斗青年
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
shell和python中互调
一.在shell脚本中调用python脚本,执行结果给予赋值 #!/bin/bash #在shell中掉用python脚本执行结果赋值给key key=`python /usr/local/pythonstudy/print.py` a=$key #对key进行过滤 b=`echo $key | awk -F\? '{print $3}'` echo $b原创 2014-05-16 10:27:34 · 1569 阅读 · 0 评论 -
makefile write
#!/usr/bin/python 'makeTextFile.py--create text file' import os ls = os.linesep #get filename while True: fname = raw_input("file name is :") if os.path.exists(fname):原创 2014-05-13 17:37:36 · 568 阅读 · 0 评论 -
os os.path
#! /usr/bin/python #coding=utf-8 import os usrdir = '/usr/local' os.chdir(usrdir) cwd = os.getcwd() print'***当前目录为: ',cwd print '创建文件' os.mkdir('example') os.chdir('example') cwd=os.getcwd() print '原创 2014-05-13 17:38:28 · 799 阅读 · 0 评论 -
queue stack
#!/usr/bin/python stack = [] def pushit(): stack.append(raw_input('enter new string: ').strip()) def popit(): if len(stack)==0: print 'cannot pop from an empty stack' else:原创 2014-05-13 17:40:35 · 516 阅读 · 0 评论 -
url
#!/usr/bin/python #coding=utf-8 import urllib print '将赶集首页的html抓取到本地,保存在g.txt文件中,同时显示下载的进度。' def fun(blocknum , blocksize ,totalsize): percent = 100.0*blocknum*blocksize/totalsize if percent原创 2014-05-13 17:43:14 · 549 阅读 · 0 评论 -
usrpasswd
#!/usr/bin/python db = {} def newuser(): prompt='login desired: ' while True: name = raw_input(prompt) if db.has_key(name): prompt='name take, try another: '原创 2014-05-13 17:41:55 · 568 阅读 · 0 评论 -
python学习
一.python的类型: 1.数字:int,long,float,complex(复数) 2.字符串: 两种取值顺序: 从左到右索引默认0开始的,最大范围是字符串长度少1 从右到左索引默认-1开始的,最大范围是字符串开头 加号(+)是字符串连接运算符,星号(*)是重复操作 print str[2:5](左取又不取) print a[-5:-2] 3.列表: 列表用[ ]原创 2014-12-21 15:42:49 · 1339 阅读 · 0 评论