摘要: 1、字母数字下划线组成2、不能以数字开头3、区分大小写4、不能以保留字命名5、描述行的单词命名你的变量,不要中文,不要拼音6、驼峰式、下划线分割 阅读全文
posted @ 2018-05-02 20:05 Karen,Z 阅读(99) 评论(0) 推荐(0)
摘要: 1、r data = open('孙悟空','r',encoding = 'utf-8').read() print(data) #该操作为文件的读操作, 2、w f = open('孙悟空','w',encoding = 'utf-8') f.write('hello world') f.writ 阅读全文
posted @ 2018-05-01 16:10 Karen,Z 阅读(164) 评论(0) 推荐(0)
摘要: #String的内置方法 st='hello world' ★1、print(st.count('l')) #统计元素在字符串的个数 #==> 3 2、print(st.capitalize()) #首字母大写 #==> Hello world ★3、print(st.center(50,'-')) 阅读全文
posted @ 2018-04-30 19:11 Karen,Z 阅读(331) 评论(0) 推荐(0)
摘要: 一、字典的定义方法: 1、dic = {'name':'Karen','age':22,'hobby':'girl','is_handsome':True} print(dic) #==>{'name':'Karen'} dic = {'name':'Karen','age':22,'hobby': 阅读全文
posted @ 2018-04-29 19:00 Karen,Z 阅读(182) 评论(0) 推荐(0)
摘要: python3.0 一、列表 a = ['1','2','3','4','5',] 二、查找(有三个命令)(索引都是从0开始的) 1、 .count #是指某个元素在列表中出现的次数 a.count('2') print(a) # ==> 2 2、 .index #根据下角标找到其对应的位置 a.i 阅读全文
posted @ 2018-04-28 16:35 Karen,Z 阅读(334) 评论(0) 推荐(0)