2019年12月5日 | 标签:

 

如果一个中文数组

keys=[“武汉酒店”,”上海酒店”,”北京酒店”,”广州酒店”,”海南酒店”,”三亚酒店”]

 

打印单个元素的时候还可以

print keys[0]

武汉

但要打印整个数组的时候

print keys

[‘\xce\xe4\xba\xba\xbe\xc6\xb5\xea’, ‘\xc9\xcf\xba\xa3\xbe\xc6\xb5\xea’, ‘\xb1\xb1\xbe\xa9\xbe\xc6\xb5\xea’, ‘\xb9\xe3\xd6\xdd\xbe\xc6\xb5\xea’, ‘\xba\xa3\xc4\xcf\xbe\xc6\xb5\xea’, ‘\xc8\xfd\xd1\xc7\xbe\xc6\xb5\xea’]

就是乱码了

如果我像打印出 中文的数组这个是没法的

又因为decode只能作用在string字符串上

所以把在python中把数组转为字符串 然后再每个数据元素加一个换行符

通过split的逆方法就可以了

也就是join

“SperateCode”.join(listarray) 可以得到一个字符串

图中就是”\n”.join(keys) 就可以得到一个每个城市一行的数组

武汉酒店
上海酒店
北京酒店
广州酒店
海南酒店
三亚酒店

 

 

如果打印数组中元素的时候也是乱码

print keys[0]

 

一共3中

指定解码

beautifulsoup html参数后加from_encoding=””

如果要知道网站编码就用html.original_encoding 就可以知道

然后再strings.encode(“”)

就可以

beautifuouspu(html,from_encoding=”gbk”
code=soup.original_encoding
print  soup.title.get_text().encode(code)

如果一个中文数组

keys=[“武汉酒店”,”上海酒店”,”北京酒店”,”广州酒店”,”海南酒店”,”三亚酒店”]

 

打印单个元素的时候还可以

print keys[0]

武汉

但要打印整个数组的时候

print keys

[‘\xce\xe4\xba\xba\xbe\xc6\xb5\xea’, ‘\xc9\xcf\xba\xa3\xbe\xc6\xb5\xea’, ‘\xb1\xb1\xbe\xa9\xbe\xc6\xb5\xea’, ‘\xb9\xe3\xd6\xdd\xbe\xc6\xb5\xea’, ‘\xba\xa3\xc4\xcf\xbe\xc6\xb5\xea’, ‘\xc8\xfd\xd1\xc7\xbe\xc6\xb5\xea’]

就是乱码了

如果我像打印出 中文的数组这个是没法的

又因为decode只能作用在string字符串上

所以把在python中把数组转为字符串 然后再每个数据元素加一个换行符

通过split的逆方法就可以了

也就是join

“SperateCode”.join(listarray) 可以得到一个字符串

图中就是”\n”.join(keys) 就可以得到一个每个城市一行的数组

武汉酒店
上海酒店
北京酒店
广州酒店
海南酒店
三亚酒店

 

 

如果打印数组中元素的时候也是乱码

print keys[0]

 

一共3中

指定解码

beautifulsoup html参数后加from_encoding=””

如果要知道网站编码就用html.original_encoding 就可以知道

然后再strings.encode(“”)

就可以

beautifuouspu(html,from_encoding=”gbk”
code=soup.original_encoding
print  soup.title.get_text().encode(code)

2019年12月3日 | 标签:

 

为什么要使用列表

列表是数组的一种 用来存储相同类型或者种类的数据 例如保存我要查询的一些列关键词的百度排名

列表和数组的区别,它是开放式的,不限定元素个数,随时扩充,

添加方便

使用list.append()可以尾部增加一个元素,list.extend()可以尾部批量增加另外一个list

list.insert(4,”name”)可以在4号位置增加

读取

list[:3] 读取前3个

list[4:] 跳过前4个读后面的

查询也方便

name in list范围布尔值

删除方便

按位置删

del list[3]

按值删

list.remove(“name”)

删同时返回值 出栈删

list.pop(“name”)

 

但是list列表只能存放一个维度的数据 并且会有重复值出现

所以就有了字典 数据类型 他专门存放配对的数据组,以key和value配对存放

其中key是不会重复的 这种特定用来过滤重复值 非常有用

#learning how to use dictionary

#1.1how to create dictionary
ddict=dict(([“name”,”stephen”],[“age”,28]))
print ddict
#1.2how to create dictionary
ddict1={“name”:”stephne”,”age”:28}
print ddict1
#1.3how to create dictionary
ddict2={}.fromkeys((“name”,”age”),”none1″)
print ddict2

#2.1how to read dictionary
print ddict1[“name”]
for key in ddict1.keys():
print key
print ddict1[key]

#2.2how to read dictionary
print “stephen” in ddict1

#3 how to add dictionary
ddict1[“height”]=53
print ddict1

#how to del dictionary
del ddict1[“height”]
print ddict1
print ddict1.pop(“name”)
ddict1.clear()
print ddict1

ss

为什么要使用列表

列表是数组的一种 用来存储相同类型或者种类的数据 例如保存我要查询的一些列关键词的百度排名

列表和数组的区别,它是开放式的,不限定元素个数,随时扩充,

添加方便

使用list.append()可以尾部增加一个元素,list.extend()可以尾部批量增加另外一个list

list.insert(4,”name”)可以在4号位置增加

读取

list[:3] 读取前3个

list[4:] 跳过前4个读后面的

查询也方便

name in list范围布尔值

删除方便

按位置删

del list[3]

按值删

list.remove(“name”)

删同时返回值 出栈删

list.pop(“name”)

 

但是list列表只能存放一个维度的数据 并且会有重复值出现

所以就有了字典 数据类型 他专门存放配对的数据组,以key和value配对存放

其中key是不会重复的 这种特定用来过滤重复值 非常有用

#learning how to use dictionary

#1.1how to create dictionary
ddict=dict(([“name”,”stephen”],[“age”,28]))
print ddict
#1.2how to create dictionary
ddict1={“name”:”stephne”,”age”:28}
print ddict1
#1.3how to create dictionary
ddict2={}.fromkeys((“name”,”age”),”none1″)
print ddict2

#2.1how to read dictionary
print ddict1[“name”]
for key in ddict1.keys():
print key
print ddict1[key]

#2.2how to read dictionary
print “stephen” in ddict1

#3 how to add dictionary
ddict1[“height”]=53
print ddict1

#how to del dictionary
del ddict1[“height”]
print ddict1
print ddict1.pop(“name”)
ddict1.clear()
print ddict1

ss

2019年12月2日 | 标签:
批量修改PPT所以文字大小 颜色 字体 vba

    只需要将以下VBA代码中红色字体,替换成需要更改的字体参数,然后将修改完成的VBA代码放入VBA编辑器中运行即可!只适合PPT2007及其以上版本!
Sub change()
Dim oShape As Shape
Dim oSlide As Slide
Dim oTxtRange As TextRange
On Error Resume Next
 For Each oSlide In ActivePresentation.Slides
   For Each oShape In oSlide.Shapes
      Set oTxtRange = oShape.TextFrame.TextRange
      If Not IsNull(oTxtRange) Then
      With oTxtRange.Font
        .Name = “楷体_GB2312”                             ‘更改为需要的字体              
        .Size = 15                                         ‘改为所需的文字大小
        .Color.RGB = RGB(Red:=255, Green:=120, Blue:=0)   ‘改成想要的文字颜色,用RGB参数表示 
      End With
      End If
    Next
 Next
End Sub
批量修改PPT所以文字大小 颜色 字体 vba反复

    只需要将以下VBA代码中红色字体,替换成需要更改的字体参数,然后将修改完成的VBA代码放入VBA编辑器中运行即可!只适合PPT2007及其以上版本!
Sub change()
Dim oShape As Shape
Dim oSlide As Slide
Dim oTxtRange As TextRange
On Error Resume Next
 For Each oSlide In ActivePresentation.Slides
   For Each oShape In oSlide.Shapes
      Set oTxtRange = oShape.TextFrame.TextRange
      If Not IsNull(oTxtRange) Then
      With oTxtRange.Font
        .Name = “楷体_GB2312”                             ‘更改为需要的字体              
        .Size = 15                                         ‘改为所需的文字大小
        .Color.RGB = RGB(Red:=255, Green:=120, Blue:=0)   ‘改成想要的文字颜色,用RGB参数表示 
      End With
      End If
    Next
 Next
End Sub