Python
默默无心
这个作者很懒,什么都没留下…
展开
-
Python 学习 ----6(字符编码)
更改文件数据类型: 使用语法:#--coding:gbk-- (文件编码改为GBK) ascii码占一个字节,Unicode统一占两个字节, utf-8:基于unicode扩展出来的可变长的编码方式,对于ascii码给一个字节的空间, 对于unicode给三个字节的空间 utf-8 <—–> Unicode(作为中介) <—–> GBK ...原创 2018-09-11 11:23:32 · 129 阅读 · 0 评论 -
Python 学习 ----2
# Author:Yan import copy #names = "ZhangSan LiSi WangWu" names = ["ZhangSan", "LiSi", "WangWu","ZhaoSi"] ''' names1 = ["1","2","3","4"] #增 names.append("LiLei&原创 2018-09-08 21:26:42 · 97 阅读 · 0 评论 -
Python -----购物车
# Author:Yan product_list = [ ('iphone',5800), ('Mac',9800), ('Watch',6800), ('Bike',900), ('Coffee',700), ('Book',80), ] shop_list = [] salary = input("Input your salary:") if salary.isdigit(): ...原创 2018-09-08 21:56:16 · 168 阅读 · 0 评论 -
Python 学习 ----3(操作字符串)(字典)
查看定义快捷键:ctrl+shift+i 字符串操作 # Author:Yan name = "my name is {name} and i am {year} old" print(name.count("a")) #对"a"进行计数 print(name.capitalize()) print(name.center(50,"-")) #一共打原创 2018-09-08 22:33:33 · 102 阅读 · 0 评论 -
Python 学习 ----4(集合)
# Author:Yan #集合无序,内容唯一 list_1 = {1,2,3,4,5,6,7,2} list_2 = {1,0,3,8,6,6,22,2} print(type(list_1)) #交集 print(list_1 & list_2) #并集 print(list_1 | list_2) #差...原创 2018-09-10 15:59:49 · 104 阅读 · 0 评论 -
Python 学习 ----5(文件编辑)
# Author:Yan ''' data = open(&quot;poem&quot;,encoding=&quot;utf-8&quot;).read() print(data) ''' ''' f = open(&quot;poem&quot;,'r',encoding=&quot;utf-8&quot;) #一个内存对象,称为 ----&amp;g原创 2018-09-10 21:56:45 · 92 阅读 · 0 评论