#coding=utf-8
# 列表推倒式子
data=[x+1 for x in range(10)]
print data even_numbers=[x for x in range(10) if x%2 == 0]
print even_numbers # 字符串
# 字符串是不可修改的,其大小也不能改变。任何试图改变字符串长度获释修改
# 内容的行为实际上是创造了一个心的修改过的字符串而已
print 'this is a string'
print "this is a string" s='django is cool'
words=s.split()
print words
print ' '.join(words)
print '::'.join(words)
print s.upper()
print s.upper().isupper()
print s.title()
print s.capitalize()
print s.count('o')
print s.find('go')
print s.startswith('python')
print s.replace('django','python')

python 代码片段8的更多相关文章

  1. Python 代码片段收藏

    list 列表相关 list 中最小值.最大值 import operator values = [1, 2, 3, 4, 5] min_index, min_value = min(enumerat ...

  2. 有用的Python代码片段

    我列出的这些有用的Python代码片段,为我节省了大量的时间,并且我希望他们也能为你节省一些时间.大多数的这些片段出自寻找解决方案,查找博客和StackOverflow解决类似问题的答案.下面所有的代 ...

  3. 2019-01-29 VS Code创建自定义Python代码片段

    续前文[日常]Beyond的歌里最多是"唏嘘"吗? - Python分词+词频最后的想法, 发现VS Code支持用户自定义代码片段: Creating your own snip ...

  4. Python - 代码片段,Snippets,Gist

    说明 代码片段来自网上搬运的或者自己写的 华氏温度转摄氏温度 f = float(input('请输入华氏温度: ')) c = (f - 32) / 1.8 print('%.1f华氏度 = %.1 ...

  5. python 代码片段26

    #coding=utf-8 ''' 使用空格而不是tab 因为无论在什么平台上开发,你的代码总是有可能会被移动或是复制到 另一不同架构的机器上,win32是4个空格,unix是8个空格,干脆 还是使用 ...

  6. python 代码片段25

    #coding=utf-8 # 虽然python是面向对象的语言,但是没有显式的构造函数概念. # python没有new关键词 class MyClass(object): pass m=MyCla ...

  7. python 代码片段23

    #coding=utf-8 #python还支持动态的实力属性,即那些没有在类定义里生命的属性, #可以"凭空"创造出来 john.tatto='Mom' #继承 class Em ...

  8. python 代码片段22

    #coding=utf-8 class AddressBookEntry(object): version=0.1 def __init__(self, name,phone): self.name ...

  9. python 代码片段20

    #coding=utf-8 # 函数 def foo(x): print x foo(123) # import httplib def check_web_server(host,port,path ...

  10. python 代码片段19

    #coding=utf-8 # 函数 def foo(x): print x foo(123) # import httplib def check_web_server(host,port,path ...

随机推荐

  1. codeforces 258div2 B Sort the Array

    题目链接:http://codeforces.com/contest/451/problem/B 解题报告:给出一个序列,要你判断这个序列能不能通过将其中某个子序列翻转使其成为升序的序列. 我的做法有 ...

  2. 白手起家搭建django app

    $django-admin.py startproject web2 $cd web2/ $python manage.py startapp blog $vim web2/settings.py 注 ...

  3. TortoiseSVN中图标的含义

    今天在使用svn时发现有好多不认识了,所以查了下svn帮助手册.借此总结了下 svn 中图标的含义 一个新检出的工作复本使用绿色的勾做重载.表示Subversion状态 正常. 在开始编辑一个文件后, ...

  4. 【转】PowerDesigner使用方法小结

    本文转自:http://www.cnblogs.com/afarmer/archive/2012/11/05/2755327.html PowerDesigner多用来进行数据库模型设计,具有SQL语 ...

  5. POJ1704 Georgia and Bob (阶梯博弈)

    Georgia and Bob Time Limit: 1000MS   Memory Limit: 10000KB   64bit IO Format: %I64d & %I64u Subm ...

  6. python基础——迭代

    python基础——迭代 如果给定一个list或tuple,我们可以通过for循环来遍历这个list或tuple,这种遍历我们称为迭代(Iteration). 在Python中,迭代是通过for .. ...

  7. mysql_3

    日期查询: mysql> select * from member where birthday > '1962-01-01';

  8. kvm NET 和 BRIDGE

    net: <interface type='network'> <mac address='52:54:00:e1:ac:43'/> <source network='d ...

  9. TransactionScope使用说明

    TransactionScope是.Net Framework 2.0滞后,新增了一个名称空间.它的用途是为数据库访问提供了一个“轻量级”[区别于:SqlTransaction]的事物.使用之前必须添 ...

  10. C#控制管理VisualSVN Server

    VisualSVN Server可以用WMI接口管理(Windows Management Instrumentation). VisualSVN Server安装的计算机中,位于%VISUALSVN ...