摘要: 单个的数据也可以作为判断条件。 任何值为0的数字,空对象都是False,任何非0数字,非空对象都是True。 阅读全文
posted @ 2019-05-10 16:22 hejp 阅读(198) 评论(0) 推荐(0) 编辑
摘要: # 字典是key-value(键 - 值) 对形式,没有顺序,通过键取出值 adict = {'name':'bob','age':30} print(len(adict)) print('bob' in adict) # False print('name' in adict) # True print(adict) adict['email'] = 'aaa@qq.com' adict[... 阅读全文
posted @ 2019-05-10 16:11 hejp 阅读(154) 评论(0) 推荐(0) 编辑
摘要: 元组与列表基本上是一样的,只是元组不可变,列表可变。 阅读全文
posted @ 2019-05-10 16:02 hejp 阅读(118) 评论(0) 推荐(0) 编辑
摘要: 列表也是序列对象,但它是容器类型,列表中可以包含各种数据。 阅读全文
posted @ 2019-05-10 15:58 hejp 阅读(170) 评论(0) 推荐(0) 编辑
摘要: 在Python中,单双引号没有区别,表示的含义是一样的。 sentence = 'tom\'s pet is a cat' # 单引号中间还有单引号,可以转义。 sentence2 = "tom's pet is a cat" # 也可以用双引号包含单引号。 sentence3 = "tom said:\"hello world!\"" sentence4 = 'tom said:"hell... 阅读全文
posted @ 2019-05-10 15:38 hejp 阅读(143) 评论(0) 推荐(0) 编辑
摘要: username = input('username: ') print('welcome', username) # print各项间默认以空格作为分隔符。 print('welcome ' + username) # 注意引号内最后的空格。 输出: 阅读全文
posted @ 2019-05-10 11:22 hejp 阅读(114) 评论(0) 推荐(0) 编辑
摘要: number = input("请输入数字:") # input 用于获取输入。 print(number) print(type(number)) # input获得的数据是字符类型。 # print(number + 100) # 执行这句会报错,不能把字符和数字做运算。 print(int(number) + 100) # int可将字符串100转换成数字100。 print(n... 阅读全文
posted @ 2019-05-10 10:50 hejp 阅读(301) 评论(0) 推荐(0) 编辑
摘要: 运算符可以分为:算术运算符,比较运算符和逻辑运算符。优先级是:算术运算符>比较运算符>逻辑运算符。 要使用括号。 阅读全文
posted @ 2019-05-10 10:39 hejp 阅读(174) 评论(0) 推荐(0) 编辑
摘要: print的常用: 阅读全文
posted @ 2019-05-10 10:29 hejp 阅读(334) 评论(0) 推荐(0) 编辑
摘要: python的语法,一般使用4个空格缩进, 阅读全文
posted @ 2019-05-10 10:22 hejp 阅读(153) 评论(0) 推荐(0) 编辑