__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. Ubuntu系统操作快捷键

    Ubuntu操作基本快捷键* 打开主菜单 = Alt + F1* 运行 = Alt + F2* 显示桌面 = Ctrl + Alt + d* 最小化当前窗口 = Alt + F9* 最大化当前窗口 = ...

  2. 从web页面启动winform程序的实现方法

    本文实现的需求是: A.通过web页面启动winform程序: B.将页面的参数传递给winform程序: C.winform程序已经启动并正在运行时,从web页面不能重新启动winform程序,只是 ...

  3. C#的注释和快速开启工具的命令

    1.注释的方法 1)sqlserver中,单行注释:——   多行注释:/****/ 2)C#中,单行注释://    多行注释:/****/ 3)C#中多行注释的快捷方式:启用ctrl+E+C ,撤 ...

  4. 不可或缺 Windows Native (3) - C 语言: 运算符,表达式,条件语句,循环语句,转向语句,空语句等

    [源码下载] 不可或缺 Windows Native (3) - C 语言: 运算符,表达式,条件语句,循环语句,转向语句,空语句等 作者:webabcd 介绍不可或缺 Windows Native  ...

  5. 重新想象 Windows 8.1 Store Apps (74) - 新增控件: Flyout, MenuFlyout, SettingsFlyout

    [源码下载] 重新想象 Windows 8.1 Store Apps (74) - 新增控件: Flyout, MenuFlyout, SettingsFlyout 作者:webabcd 介绍重新想象 ...

  6. csharp: Sound recording

    using System; using System.Collections.Generic; using System.Linq; using System.Text; using Microsof ...

  7. LinQ实战学习笔记(三) 序列,查询操作符,查询表达式,表达式树

    序列 延迟查询执行 查询操作符 查询表达式 表达式树 (一) 序列 先上一段代码, 这段代码使用扩展方法实现下面的要求: 取进程列表,进行过滤(取大于10M的进程) 列表进行排序(按内存占用) 只保留 ...

  8. 详解JavaScript函数模式

    JavaScript设计模式的作用是提高代码的重用性,可读性,使代码更容易的维护和扩展.在javascript中,函数是一类对象,这表示他可以作为参数传递给其他函数:此外,函数还可以提供作用域. 创建 ...

  9. virtualbox迁移至vcenter/vmware workstation

    参考文献: http://www.itsecurenet.com/virtualbox-ova-to-vsphere-ovf/ http://www.techrepublic.com/blog/win ...

  10. Android中方便好用的倒计时类

       一.使用api提供的类进行操作 Android提供了CountDownTimer来让我们进行倒计时,可以让我们很方便的进行倒计时的操作.使用方式也很简单,下面直接贴代码就好了: package ...