python学习
文章平均质量分 74
davidcheungchina
这个作者很懒,什么都没留下…
展开
-
Python chapter 8 learning notes
定义一个函数 For example, def greet_user():#定义函数 print("Hello!") Now, we just need to input greet_user() and Hello! will be shown on the screen. o 向函数传递信息 其实这一点和C语言基本是一致的。这个函数其实就是一个子函数,可原创 2017-10-17 22:00:41 · 259 阅读 · 0 评论 -
Python chapter 2&3 learning notes
方法是Python对数据执行的操作。 For example, Upper() 全部大写 Lower() 全部小写 Title() 首字母大写 rstrip() 删除多余空格(此时的删除都是暂时的,非永久。如需永久需要重新幅值给原变量) 当在字符串中需要使用数字的时候,应在该数字的变量名前使用str()以避免错误 For example, If yo原创 2017-10-15 20:07:49 · 214 阅读 · 0 评论 -
Python chapter 4 learning notes
1. About loop · Indentation means these sentences or this sentence belong(s) to this loop.Such as, magicians=['david','joe','kite','john'] for magician in magicians:# loop p原创 2017-10-15 20:29:09 · 267 阅读 · 0 评论 -
Python chapter 5 learning notes
一个简单例子 在python中,检查是否相等时,大小写不同默认是不相等的。如果需要不考虑大小写,则可把他们都统一转换成小写。 检查多个条件时有以下两种情况: 必须同时符合多种情况:利用and语句。例如:if (age_0>21) and (age_1 多种情况符合其一即可:用or。例如: if (age_060)原创 2017-10-15 20:29:57 · 223 阅读 · 0 评论 -
Python chapter 6 learning notes
A simple dictionary 1 2 alien_0 = {'color': 'green','point': 5} print(alien_0['color'])#使用大括号 The window will show green. l Using dictionary n Ad原创 2017-10-15 20:30:34 · 316 阅读 · 0 评论 -
Python chapter 7 learning notes
函数input()工作原理 n 示例演示了一种创建多行字符串的方式,第一行将消息的前半部分存储在变量prompt中,第二行,+=在存储在prompt中的字符串末尾附件一个字符串。 例如: prompt = "If you tell us who you are, we can personalize the messages you see." prompt +="\nW原创 2017-10-15 20:31:03 · 260 阅读 · 0 评论