__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的更多相关文章

  1. zookeeper kazoo Basic Usage

    http://kazoo.readthedocs.org/en/latest/basic_usage.html Basic Usage Connection Handling To begin usi ...

  2. [TensorFlow] Basic Usage

    Install TensorFlow on mac Install pip # Mac OS X $ sudo easy_install pip $ sudo easy_install --upgra ...

  3. 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 ...

  4. python logging usage

    python中,logging模块主要是处理日志的. 所谓日志,可理解为在软件运行过程中,所记录的的一些运行情况信息 软件开发人员可以根据自己的需求添加日志,日志可以帮助软件开发人员 了解软件的运行信 ...

  5. [Python] Basic operations in Pycharm

    From: http://learnpythonthehardway.org/book Comment with line comment: Ctrl + slash Run: Shift + F10 ...

  6. Python Basic 01.Basic

    01.variable ''' 변수(variable) - 자료(data)를 임시(휘발성) 저장하는 역할 - 실제 자료가 아닌 자료의 주소를 저장한다.(참조변수) ''' # 1. 변수 ...

  7. python basic

    #遍历一个序列,很多传统语言过来的,习惯用下标遍历,Python中序列是可迭代的,直接for即可! colors=['red','green','blue','yellow'] for color i ...

  8. python netifaces usage

    1. install python dev sudo apt-get install python-dev 2.download src code and install https://pypi.p ...

  9. 【C++/C】指针基本用法简介-A Summary of basic usage of Pointers.

    基于谭浩强老师<C++程序设计(第三版)>做简要Summary.(2019-07-24) 一.数组与指针 1. 指针数组 一个数组,其元素均为指针类型数据,该数组称为指针数组.(type_ ...

随机推荐

  1. 微软modern.IE网站,多版本IE免费测试工具集

    微软今天发布了modern.IE,这是一系列免费的.针对Web 开发者的测试工具和资源集合网站,微软希望以此来帮助开发者更轻松地实现跨 IE 和其他现代浏览器.跨设备的兼容性,其他还有代码检测工具.标 ...

  2. 【循序渐进学Python】9.异常处理

    1. 抛出异常和自定义异常 Python用异常对象(exception object)表示异常情况,遇到错误后,会引发异常.如果异常对象并未被处理或捕捉,程序就会用所谓的回溯(Traceback,一种 ...

  3. 【循序渐进学Python】6.Python中的函数

    1. 创建函数 一个函数代表一个行为并且返回一个结果(包括None),在Python中使用def关键字来定义一个函数,如下: def hello(name): print 'hello,' + nam ...

  4. jquery实现表格中点击相应行变色功能

    对于一个表格,为了使我们选中的项更容易区分,需要为选中项添加高亮,同时也需要,将其他项的高亮形式去除.类似于: <!DOCTYPE html> <html lang="en ...

  5. XmlNodeList循环读取节点值

    foreach (XmlNode item in XmlNodeList) { string oid = item.SelectSingleNode("oid").InnerTex ...

  6. POJ 3233 Matrix Power Series 矩阵快速幂+二分求和

    矩阵快速幂,请参照模板 http://www.cnblogs.com/pach/p/5978475.html 直接sum=A+A2+A3...+Ak这样累加肯定会超时,但是 sum=A+A2+...+ ...

  7. [PHP] java读取PHP接口数据

    和安卓是一个道理,读取json数据 PHP文件: <?php class Test{ //日志路径 const LOG_PATH="E:\phpServer\Apache\logs\\ ...

  8. Hibernate关联映射及高级查询

    一.Hibernate中的关联关系 1.1.单向一对多关联关系 按照以下步骤配置hibernate中持久化类的一对多对象关联: (1).持久化类添加关联类的相关属性及getter/setter方法. ...

  9. PHP 操作mongodb api大部分方法

    <?php /* PHP mongodb * 全部curd操作 * @author:xiaojiang * @date: 2014-10-27 */ //查看 mongo类版本 1.30 以后版 ...

  10. C# Winform 窗体美化

    using System; using System.ComponentModel; using System.Diagnostics; using System.Drawing; using Sys ...