版权声明:本文为博主原创文章,原文均发表自http://www.yushuai.me。未经允许,禁止转载。 https://blog.csdn.net/davidcheungchina/article/details/78243401

方法是Python对数据执行的操作。

For example,

Upper() 全部大写

Lower() 全部小写

Title() 首字母大写

rstrip() 删除多余空格(此时的删除都是暂时的,非永久。如需永久需要重新幅值给原变量)

当在字符串中需要使用数字的时候,应在该数字的变量名前使用str()以避免错误

For example,

If you want output this sentence "I am 22 years old."

And your code will be

a=22# assumption

print("I am " + str(a) + "years old.")#Either "" or '' is ok.

There are the correct codes.

About Python List

Some skills:

1.      if you want to output the last element in the list, you can use this code:

list[-1]#in this place, list means the name of this list

Similarly, if you want to input the second to last number, you can use:

list[-2]

2.      some methods to modify, add or delete elements.

·        modify the element:

sights[0]='Beijing' means change the first element in the list sights to Beijing.

·        add element:

sights.append('Beijing') means add Beijing to the last of the list sights, sights.

insert(1, 'Beijing') means add Beijing to the place between the first element and the third element.

·        delete element:

del sights[0] means delete the first element  from the list.

poped_sight=sights.pop() means we can still use it when we delete the last element.

One thing to be noted, if we use poped_sight=sights.pop(1), it means that we still use the second element when we delete it.

sights.remove('Beijing') means delete the Beijing from the list. (If there are many Beijing in the list, this method only can delete the first Beijing.)

3.      Sort:

·        sort & alphabetically forever: use sort()

For example, sight.sort().

If we use sight.sort(reverse =True), it means reverse order.

·        temporary sort: use sorted() function.

For example, print(sorted(sights)).We can also use sorted(sights, reverse = True) to reverse order.

·        reverse order print: sights.reverse()

·        How to know the length of the list? The answer is use len() function.

Python chapter 2amp;3 learning notes相关推荐

  1. Python Learning Notes - 2

    Python Learning Notes - 2 主体感想 我们要想表达出一个事件(event),或一系列相联系的事件(events series that construct a system w ...

  2. Python Tools for Machine Learning

    2019独角兽企业重金招聘Python工程师标准>>> 原文:https://www.cbinsights.com/blog/python-tools-machine-learnin ...

  3. Think Python - Chapter 12 Tuples

    12.1 Tuples are immutable(元组是不可变的) A tuple is a sequence of values. The values can be any type, and ...

  4. 使用Python发送和读取Lotus Notes邮件

    转载自 https://blog.csdn.net/u013271714/article/details/78364932 转载自: Blog:Why So Serious  Github: LeoL ...

  5. [翻译] 神经网络与深度学习 第六章 深度学习 - Chapter 6 Deep learning

    目录: 首页 译序 关于本书 关于习题和难题 第一章 利用神经网络识别手写数字 第二章 反向传播算法是如何工作的 第三章 提升神经网络学习的效果 第四章 可视化地证明神经网络可以计算任何函数 第五章 ...

  6. 【Learning Notes】线性链条件随机场(CRF)原理及实现

    1. 概述 条件随机场(Conditional Random Field, CRF)是概率图模型(Probabilistic Graphical Model)与区分性分类( Discriminativ ...

  7. Python 基础 - Day 5 Learning Note - 模块 之 标准库:xml (9)

    xml 模块介绍 和json一样,适用于不同语言及程序的数据交换的协议.但是json用起来更简单,并有代替xml的趋势. 现在多数金融数据提供方(e.g. bloombegy)还在用xml的方式. 在 ...

  8. Python 基础 - Day 2 Learning Note - 字符转编码操作

    前情提要:字符编码 python解释器在加载 .py 文件中的代码时,会对内容进行编码(默认ascill).ASCILL有255个字符,包括英语和西欧字符,不包括中文.汉字处理靠GBK, window ...

  9. Machine Learning Notes Ⅲ

    欠拟合与过拟合 欠拟合:特征选择不够或所选的函数次数过低导致拟合不完全,一些内在性质没有被反映出来. 过拟合:特征选择过多或所选的函数次数过高导致拟合仅仅反映了样本数据的特殊性质,忽略了内在联系. 解 ...

  10. Python深度学习(Deep Learning with Python) 中文版+英文版+源代码

    Keras作者.谷歌大脑François Chollet最新撰写的深度学习Python教程实战书籍(2017年12月出版) 介绍深入学习使用Python语言和强大Keras库,详实新颖.PDF高清中文 ...

最新文章

  1. Ubuntu读取/root/.profile时发现错误:mesg:ttyname fa
  2. 关于NullPointerException
  3. 那些年我们程序员欠下的技术债
  4. 【最新合集】编译原理习题(含答案)_答案全集_MOOC慕课 哈工大陈鄞
  5. 【bzoj3555】[Ctsc2014]企鹅QQ 简单哈希
  6. @kafkalistener中id的作用_SSM框架(十一):Spring框架中的IoC(1)
  7. linux修改文件权限和用户组管理小结
  8. 使用SQL存储过程有什么好处 用视图有什么好处
  9. 解决Flash挡住层用z-index无效的问题
  10. LeetCode(500)——键盘行(JavaScript)
  11. 巨坑:从Sqoop导入MySQL导入TINYINT(1)类型数据到hive(tinyint),数据为null
  12. 瑞典皇家理工学院工程类表
  13. 日期转换成时间戳的问题
  14. 全国计算机等级考试准考证下载 怎么弄
  15. 微信支付全部详细流程
  16. 最小生成树-Prim + Kruskal算法
  17. 2022年安全员-A证操作证考试题模拟考试平台操作
  18. 成为会带团队的技术人 跨团队:没有汇报线的人和事就是推不动?
  19. iOS公司开发者账号申请 营业执照
  20. Debian Bullseye 更新源备份

热门文章

  1. Java NIO之缓冲区Buffer
  2. Spring security3入门(转)
  3. NVIDIA Linux Display Driver 100.14.09
  4. 【CoreBluetooth】iOS 系统蓝牙框架
  5. 59 | 测试专栏特别放送 | 答疑解惑第七期
  6. windows下把文件压缩成tar.gz格式
  7. ifconfig源码分析之与内核交互数据
  8. c++值传递和引用及指针传递区别
  9. Java为何大行其道
  10. liunx 之 redHat 下 java 环境的配置和安装