# st='hello kitty {name} is {age}'
#
# print(st.count('l')) # 统计元素个数
# print(st.capitalize()) # 首字母大写
# print(st.center(50,'#')) # 居中
# print(st.endswith('tty3')) # 判断是否以某个内容结尾
# print(st.startswith('he')) # 判断是否以某个内容开头
# print(st.expandtabs(tabsize=20))
# print(st.find('t')) # 查找到第一个元素,并将索引值返回
# print(st.format(name='alex',age=37)) # 格式化输出的另一种方式 待定:?:{}
# print(st.format_map({'name':'alex','age':22}))
# print(st.index('t'))
# print('asd'.isalnum())
# print('12632178'.isdecimal())
# print('1269999.uuuu'.isnumeric())
# print('abc'.isidentifier())
# print('Abc'.islower())
# print('ABC'.isupper())
# print(' e'.isspace())
# print('My title'.istitle())
# print('My tLtle'.lower())
# print('My tLtle'.upper())
# print('My tLtle'.swapcase())
# print('My tLtle'.ljust(50,'*'))
# print('My tLtle'.rjust(50,'*'))
# print('\tMy tLtle\n'.strip())
# print('\tMy tLtle\n'.lstrip())
# print('\tMy tLtle\n'.rstrip())
# print('ok')
# print('My title title'.replace('itle','lesson',1))
# print('My title title'.rfind('t'))
# print('My title title'.split('i',1))
# print('My title title'.title()) #摘一些重要的字符串方法
#1 print(st.count('l'))
# print(st.center(50,'#')) # 居中
# print(st.startswith('he')) # 判断是否以某个内容开头
# print(st.find('t'))
# print(st.format(name='alex',age=37)) # 格式化输出的另一种方式 待定:?:{}
# print('My tLtle'.lower())
# print('My tLtle'.upper())
# print('\tMy tLtle\n'.strip())
# print('My title title'.replace('itle','lesson',1))
# print('My title title'.split('i',1))
 # a=list()
# print(a) # dic={'name':'alex'} # dic1={}
# dic2=dict((('name','alex'),))
# print(dic2) # dic3=dict([['name','alex'],])
# print(dic3)
 # ret2=dic1.setdefault('hobby','girl')
# print(dic1)
# print(ret2) # dic3={'age': 18, 'name': 'alex', 'hobby': 'girl'}
#
# print(dic3['name'])
#
# print(list(dic3.keys()))
# print(list(dic3.values()))
# print(list(dic3.items())) # li=[1,2,34,4]
# li[2]=5
# dic3={'age': 18, 'name': 'alex', 'hobby': 'girl'}
# dic3['age']=55
# print(dic3) # dic4={'age': 18, 'name': 'alex', 'hobby': 'girl'}
# # dic5={'1':'111','2':'222'}
# dic5={'1':'111','name':'222'}
#
# dic4.update(dic5)
# print(dic4)
# print(dic5)

 # dic1={'name':'alex'}
# dic1['age']=18
# print(dic1)
 # dic5 = {'name': 'alex', 'age': 18, 'class': 1}

 # dic5.clear() # 清空字典
# print(dic5)
# del dic5['name'] #删除字典中指定键值对
# print(dic5) # print(dic5.pop('age')) #删除字典中指定键值对,并返回该键值对的值
# ret=dic5.pop('age')
# print(ret)
# print(dic5) # a = dic5.popitem() #随机删除某组键值对,并以元组方式返回值
# print(a, dic5) # del dic5 #删除整个字典
# print(dic5)

06 python下的更多相关文章

  1. python下的select模块使用 以及epoll与select、poll的区别

    python下的select模块使用 以及epoll与select.poll的区别 先说epoll与select.poll的区别(总结) 整理http://www.zhihu.com/question ...

  2. python下ssh的简单实现

    python下的ssh都需要借助第三方模块paramiko来实现,在使用前需要手动安装. 一.python实现ssh (1) linux下的ssh登录 root@ubuntu:~# ssh morra ...

  3. python下编译py成pyc和pyo

     python下编译py成pyc和pyo   其实很简单, 用 python -m py_compile file.py python -m py_compile /root/src/{file1,f ...

  4. Python下划线与命名规范

    Python下划线与命名规范 先看结论,节省只想知道答案你的宝贵时间: _xxx 不能用于from module import * 以单下划线开头的表示的是protected类型的变量.即保护类型只能 ...

  5. python下的orm基本操作(1)--Mysql下的CRUD简单操作(含源码DEMO)

    最近逐渐打算将工作的环境转移到ubuntu下,突然发现对于我来说,这ubuntu对于我这种上上网,收收邮件,写写博客,写写程序的时实在是太合适了,除了刚接触的时候会不怎么完全适应命令行及各种权限管理, ...

  6. Python下科学计算包numpy和SciPy的安装

    转载自:http://blog.sina.com.cn/s/blog_62dfdc740101aoo6.html Python下大多数工具包的安装都很简单,只需要执行 “python setup.py ...

  7. python下的复杂网络编程包networkx的安装及使用

    由于py3.x与工具包的兼容问题,这里采用py2.7 1.python下的复杂网络编程包networkx的使用: http://blog.sina.com.cn/s/blog_720448d30101 ...

  8. Python学习入门基础教程(learning Python)--5.1 Python下文件处理基本过程

    Python下的文件读写操作过程和其他高级语言如C语言的操作过程基本一致,都要经历以下几个基本过程. 1. 打开文件 首先是要打开文件,打开文件的主要目的是为了建立程序和文件之间的联系.按程序访问文件 ...

  9. python下读取excel文件

    项目中要用到这个,所以记录一下. python下读取excel文件方法多种,用的是普通的xlrd插件,因为它各种版本的excel文件都可读. 首先在https://pypi.python.org/py ...

随机推荐

  1. js barcode 打印

    新建 html <!DOCTYPE HTML> <html lang="en-US"> <head> <meta charset=&quo ...

  2. URI,url简介

    URI,URL是什么? URI :Uniform Resource Identifier,统一资源标识符: URL:Uniform Resource Locator,统一资源定位符: URN:Unif ...

  3. vim粘贴缩进问题

    vim不支持直接从其他应用复制内容粘贴过来,而是模拟用户键盘输入来实现的,一般设置vim在换行时自动以上一行的的缩进为初始位置,这样就会导致复制过来的内容出现缩进错乱. set paste 解决粘贴乱 ...

  4. webpack学习笔记(三)

    访问网址: https://github.com/webpack/analyse "scripts": { "dev-build": "webpack ...

  5. linux 保留文件 其余删除

    set选项与shopt选项是两组不同的内容,用set -o和shopt -p可以分别查看两个组所有的打开和关闭的条目, 在默认状态下,有些是打开的,有些是关闭的,shopt各选项随着bash版本的更新 ...

  6. linux --- 1.初始linux

    一.计算机简单认识 1.服务器的硬件 ①输入单元:键盘,鼠标,读卡器,触摸屏,手写板 ②主机部分:主板,cpu,显卡,内存条,硬盘,网卡,声卡,电池,散热器 ③输出单元:显示器,打印机 2.内存,cp ...

  7. C语言编程知识点

    (1)预处理指令#define 声明一个常数,用以表明1年中有多少秒(忽略闰年问题):#define SECONDS_PER_YEAR (60 * 60 * 24 * 365)UL 1) #defin ...

  8. bvlc_reference_caffenet网络权值可视化

    一.网络结构 models/bvlc_reference_caffenet/deploy.prototxt 二.显示conv1的网络权值 clear; clc; close all; addpath( ...

  9. [综] meanshift算法

    Meanshift,聚类算法 http://www.cnblogs.com/liqizhou/archive/2012/05/12/2497220.html 记得刚读研究生的时候,学习的第一个算法就是 ...

  10. Excel函数之rank应用

    该函数的功能就是对现有数据指标进行排名 示例:对产品进行销售总额的排名 首先要知道排名需要用到rank函数 number参数就是你要进行排名的数据 ref参数就是该指标需要在哪个区域内进行比较定位排名 ...