python Basic usage
__author__ = 'student'
l=[]
l=list('yaoxiaohua')
print l
print l[0:2]
l=list('abc')
print l*3
l.append(4)
print l
l.extend('de')
print l
print l.count('a')
l.sort()
print l
l.reverse()
print l
l[0:2]=[1,2,3]
print l
print list(map (ord,'spam'))
l = ['abc', 'ABD', 'aBe']
l.sort(key=str.lower) # sort in place not return new object, be ware of this
print l
print sorted(l, key=str.upper, reverse=True) #return new object not change l
print l '''
while True:
reply=raw_input("please input what you want to say:")
if reply=='exit':
break
else:
print reply.upper()
'''
print 100**2
a,b='A','B'
print a
print a,b L = [1, 2]
M = L # L and M reference the same object
L = L + [3, 4] # Concatenation makes a new object
print L, M # Changes L but not M
L = [1, 2]
M = L
L += [3, 4] # But += really means extend
print L, M # M sees the in-place change too! L = L.append(4) # But append returns None, not L
print(L) # So we lose our list! None data = (123, 'abc', 3.14)
for i, value in enumerate(data):
print i, value import re
m=re.match(r'\d+','123:abc')
if m is not None : print m.group() import random
for i in range(1,10):
print random.choice(xrange(10)) l=[1,2]
sum= lambda a,b:a+b
print 'sum is :' , sum(*l) # parse the list to function parameters
d={'a':1,'b':2}
print 'sum is ', sum(**d) # ** parse the dictionary to function parameters with open(r'd:\test.txt','w') as file: # with clause the system will release resource automatically
for x in range(0,26,1):
file.write(chr(ord('a')+x))
file.write('\n')
with open(r'd:\test.txt','r') as file:
for line in file:
print line.rstrip() # rstrip remove the end line in the string
python Basic usage的更多相关文章
- zookeeper kazoo Basic Usage
http://kazoo.readthedocs.org/en/latest/basic_usage.html Basic Usage Connection Handling To begin usi ...
- [TensorFlow] Basic Usage
Install TensorFlow on mac Install pip # Mac OS X $ sudo easy_install pip $ sudo easy_install --upgra ...
- Python basic (from learn python the hard the way)
1. How to run the python file? python ...py 2. UTF-8 is a character encoding, just like ASCII. 3. ro ...
- python logging usage
python中,logging模块主要是处理日志的. 所谓日志,可理解为在软件运行过程中,所记录的的一些运行情况信息 软件开发人员可以根据自己的需求添加日志,日志可以帮助软件开发人员 了解软件的运行信 ...
- [Python] Basic operations in Pycharm
From: http://learnpythonthehardway.org/book Comment with line comment: Ctrl + slash Run: Shift + F10 ...
- Python Basic 01.Basic
01.variable ''' 변수(variable) - 자료(data)를 임시(휘발성) 저장하는 역할 - 실제 자료가 아닌 자료의 주소를 저장한다.(참조변수) ''' # 1. 변수 ...
- python basic
#遍历一个序列,很多传统语言过来的,习惯用下标遍历,Python中序列是可迭代的,直接for即可! colors=['red','green','blue','yellow'] for color i ...
- python netifaces usage
1. install python dev sudo apt-get install python-dev 2.download src code and install https://pypi.p ...
- 【C++/C】指针基本用法简介-A Summary of basic usage of Pointers.
基于谭浩强老师<C++程序设计(第三版)>做简要Summary.(2019-07-24) 一.数组与指针 1. 指针数组 一个数组,其元素均为指针类型数据,该数组称为指针数组.(type_ ...
随机推荐
- private、 protected、 public、 internal 修饰符
private : 私有成员, 在类的内部才可以访问. protected : 保护成员,该类内部和继承类中可以访问. public : 公共成员,完全公开,没有访问限制. internal: 在同一 ...
- Microsecond and Millisecond C# Timer[转]
文章转至:http://www.codeproject.com/Articles/98346/Microsecond-and-Millisecond-NET-Timer IntroductionAny ...
- MySQL联接操作
在MySQL中,联接是一种对表的引用, 多表联接类型: 1.笛卡尔积(交叉联接):在MySQL中为CROSS JOIN或省略JOIN,如: select * from course, teachcou ...
- Qt 框架 开发HTTP 服务器 开发记录
最近需求需要开发一款 HTTP ,然后由于先前接触过Qt,就直接用Qt写HTTP服务器了,也是为了当作练手,要不然是直接上HTTP框架的. 后端用C++ Qt框架 前端为了练手 当然是纯生的 js h ...
- [moka同学笔记]yii2.0 advanced高级版 安装配置 与 rbac (Ⅰ)
1.下载地址:http://www.yiichina.com/download,下载 Yii2 的高级应用程序模板 2.配置与安装 在服务器www目录下yii2test [下载下来更改advance ...
- Linux下建立Nexus私服
Linux下建立Nexus私服 要安装3个东西,然后配置私服: 1.JDK 2.Maven 3.Nexus 然后配置 1.JDK的安装 下载JDK安装包,格式为RPM格式,安装即可 安装程序 #rpm ...
- FlexPaper 2.2.1介绍与提取嵌入的文档
源起看到某个公司内网的公文使用FlexPaper组件来显示文档,在这儿是GoogleCode Project的主页, 还有现在的官方主页.目前FlexPaper是个开源项目,GPLv3 ...
- Android5.0新特性——图片和颜色(drawable)
图片和颜色 tint属性 tint属性一个颜色值,可以对图片做颜色渲染,我们可以给view的背景设置tint色值,给ImageView的图片设置tint色值,也可以给任意Drawable或者NineP ...
- HTML Jquery
在<网页制作Dreamweaver(悬浮动态分层导航)>中,运用到了jQuery的技术,轻松实现了菜单的下拉.显示.隐藏的效果,不必再用样式表一点点地修改,省去了很多麻烦,那么jQuery ...
- [Architecture Pattern] Repository实作查询功能
[Architecture Pattern] Repository实作查询功能 范例下载 范例程序代码:点此下载 问题情景 在系统的BLL与DAL之间,加入Repository Pattern的设计, ...