python学习过程中知识点和遇到的坑记录

记录python学习过程知识点
1. BeautifulSoup简单用法
req1 = requests.get(url)req1 = requests.get(url)
result1 = BeautifulSoup(result1,‘lxml’)
divs = result1.find_all(‘div’)
获取所有的div
content = result1.find(id=‘chaptercontent’)
获取id=chaptercontent的参数
2.os应用
os.chdir(self.folder_path) #切换路径至上面创建的文件夹
创建文件夹方法

	def mkdir(self, path):  ##这个函数创建文件夹
		path =path.strip() #移除字符串头尾指定的字符(默认为空格)
		isExists = os.path.exists(path) #判断是否存在某文件,如果存在,则告诉用户。否则写入数据
		if not isExists:
		    print('创建名字叫做', path, '的文件夹')
		    os.makedirs(path)
		    print('创建成功!')
		else:
		    print(path, '文件夹已经存在了,不再创建')

3.运行pycharm程序,一直提醒配置错误,但实际上有重新导入python.py模块。强制运行代码,提示以下内容:error running ‘xxx’ @NotNull method com/intellij/execution/configurations/generalCommandLine.getExePath must not return null
重新配置解析器:打开setting
python学习过程中知识点和遇到的坑记录
选择下拉按钮
python学习过程中知识点和遇到的坑记录
选择安装过的版本点击Apply 然后okpython学习过程中知识点和遇到的坑记录