__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. WPF 中获取DataGrid 模板列中控件的对像

    WPF 中获取DataGrid 模板列中控件的对像 #region 当前选定行的TextBox获得焦点 /// <summary> /// 当前选定行的TextBox获得焦点 /// &l ...

  2. knockout.js的简介和简单使用

    1.knockout简介knockout是一个轻量级的UI类库,通过MVVM模式使JavaScript前端UI简单化knockout有四大重要概念:1)声明式绑定:使用简明移读的语法很容易地将模型(m ...

  3. javascript:Bing Maps AJAX Control, Version 7.0

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...

  4. ASP.NET MVC进阶一

    一.控制器相关 在Controller类中方法访问级别为public的方法,就是行为(Action). 如果不希望Controller类中的方法成为Action(可以在地址栏中被访问),有两种实现方式 ...

  5. TCMalloc优化MySQL、Nginx内存管理

    TCMalloc的全称为Thread-Caching Malloc,是谷歌开发的开源工具google-perftools中的一个成员. 与标准的glibc库的Malloc相比,TCMalloc库在内存 ...

  6. Python基础(一),Day1

    python的安装 python2.x与3.x的部分区别 第一个python程序 变量 字符编码 注释 格式化字符串 用户输入 常用的模块初始 if判断 循环语句 作业 1.python的安装 可以在 ...

  7. 访问SAP的Domain的Value Range

    访问Domain的Value Range有两种方法: 1.直接访问表 dd07l和dd07T     select * from dd07l            where domname   = ...

  8. UIView简单动画

    UIView动态实现的效果有以下几种: 1.动态改变frame 2.动态改变color 3.动态改变alpha 4.动态改变bounds 首先,我们先看几种BasicView动画 #pragma ma ...

  9. 如何让 UITableViewCell 中的 imageView 大小固定

    UITableView可以算是使用频率最高的组件之一的,在开发过程中经常需要展示一些简单的信息列表常见列表布局 如图,很多页面其实就是这种展示结果,通常需要imageView,textLabel,de ...

  10. HTML列表元素

    HTML定义了3类列表: 1.有序列表(通常用数字编号) 2.无序列表(通常前面加原点) 3.自定义列表(列表项目,带有集成的定义) 有序列表和无序列表均为列表中的每一项使用列表项元素(<li& ...