![](https://img-blog.csdnimg.cn/20201014180756923.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
Python基础
轻羽羽
学编程的美食爱好者,
有问题欢迎邮件联系szysunyi@163.com
展开
-
爬虫笔记---有关post/get请求以及payload数据的填写
一、post请求(以网站登陆为例)import requests# agent:浏览器信息,在与网站交互时用到agent = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.92 Safari/537.36'headers = {"Use...原创 2020-04-29 10:47:55 · 3141 阅读 · 0 评论 -
Linux后台执行Python程序
nohup python3 -u test.py >test.log 2>&1 &原创 2019-12-13 14:08:44 · 115 阅读 · 0 评论 -
python基础------- *与**
def fun(*args, **kwargs):... print('args=', args)... print('kwargs=', kwargs)fun(1, 2, 3, 4, A='a', B='b', C='c', D='d')args= (1, 2, 3, 4)kwargs= {'A': 'a', 'B': 'b', 'C': 'c', 'D': 'd'}...原创 2019-11-17 13:54:10 · 78 阅读 · 0 评论 -
python---------字符串格式化format
print("model saved to {}".format("save_path"))print("model saved to %s" % "save_path")## model saved to save_path## model saved to save_path### 普通的形式'my name is {} ,age {}'.format('hoho',18)'my...原创 2019-11-17 13:52:29 · 371 阅读 · 0 评论 -
setup安装
python setup.py buildpython setup.py install原创 2019-11-17 13:51:53 · 460 阅读 · 0 评论 -
python------异常、lambda表达式
try: 正常操作语句1(先)except <异常名1>: # 指定异常发生时执行 异常处理语句1except: #其他异常发生时执行 异常处理语句2else: # 没有异常时执行 正常操作语句2finally: # 无论结果怎样都执行 正常操作语句3...原创 2019-11-16 13:06:46 · 190 阅读 · 0 评论 -
命名元组namedtuple
import collectionsPerson=collections.namedtuple('Person','name age gender')print( 'Type of Person:',type(Person))# Type of Person: <class 'type'>Bob=Person(name='Bob',age=30,gender='male')...原创 2019-11-16 13:06:15 · 245 阅读 · 0 评论 -
python---------类的定义、类文件的导入
定义类:class Point(object): # 类名首字母大写,父类object #子类拥有父类函数,初始化方法默认与父类一致(除非添加新的初始化方法)实例化(对象):black = Point()对象的属性:black.x = 3.0 # 可修改对象black可以作为函数的返回值class Student(object): def __init__(se...原创 2019-11-16 13:05:01 · 491 阅读 · 0 评论 -
列表、矩阵、数组的转化
转数组:myarray = np.array(mylist)转矩阵:mymatrix = np.mat(mylist)转列表:mylist = myarray.tolist()原创 2019-11-16 13:03:18 · 244 阅读 · 0 评论 -
元组、字典、列表作为函数参数
l=[1,2,3]p=(1,2,3)d={'s':3,'m':4,'c':5}def test(*args,**kwargs): print(args,kwargs) test(l) # ([1,2,3],){}test(*l) ## (1,2,3){}test(l,d) # ([1,2,3],{'s':3,'m':4,'c':5}){}test(p,d) # ((2,3,4...原创 2019-11-16 13:02:11 · 251 阅读 · 0 评论 -
Python语言之enumerate函数详细介绍
#enumerate() 函数用于将一个可遍历的数据对象(如列表、元组或字符串)组合为一个索引序列,同时列出数据和数据下标,一般用在 for 循环当中# 将整数序列编码为二进制矩阵def vectorize_sequences(sequences,dimension=10000): results = np.zeros((len(sequences),dimension)) # 形状(l...原创 2019-11-16 13:00:41 · 695 阅读 · 0 评论