![](https://img-blog.csdnimg.cn/20201014180756780.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
python
十四呀
服务端开发
展开
-
python 常用方法-路径处理
import osos.getcwd() #获取当前路径os.walk(path) #获取一个元组 (起始的路径,路径下的文件夹,起始路径下的文件) 第一个为起始路径,第二个为起始路径下的文件夹,第三个是起始路径下的文件。遍历文件夹下面的某种格式的文件 比如txt for path, dics, files in os.walk(file_dir): for file in fi原创 2017-09-27 13:51:12 · 519 阅读 · 0 评论 -
python问题
def accum(s): out=” for i,ch in enumerate(s.upper()): out +=ch out +=ch.lower()*i out +=’-’ return out.strip(‘-‘)def accum(s): out=” for i,ch in enum原创 2017-09-28 09:47:50 · 197 阅读 · 0 评论 -
python常用方法-变量处理
1.字符转ascii数字ord (字符) = ascii表里的位置chr (ascii表里的位置) = 字符2.迭代中获取list/str下标for i,ch in enumerate(str/list):i 下标ch 字符3.获取字符串中某个字符的下标在S字符串里面在[start,end)的区间里查找substr的下标 S.index(substr,start ,end) ->原创 2017-09-28 14:44:01 · 310 阅读 · 0 评论 -
python-安装mysql(win64)
经过各种报错,总结方法如下: 1.https://www.lfd.uci.edu/~gohlke/pythonlibs/ 下载: MySQL_python‑1.2.5‑cp27‑none‑win_amd64.whl2.执行 pip install MySQL_python‑1.2.5‑cp27‑none‑win_amd64.whl原创 2018-01-04 08:58:57 · 1920 阅读 · 0 评论 -
python-package(beautifulsoup)-1
1.beautifulsoup对象-bsObj获取标题from urllib.request import urlopenfrom urllib.error import HTTPError ,URLErrorfrom bs4 import BeautifulSoupdef getTitle(url): try: html = urlopen(url) excep原创 2018-01-14 15:12:52 · 284 阅读 · 0 评论 -
python-package(beautifulsoup)-2
Navigating trees 导航树from urllib.request import urlopenfrom urllib.error import HTTPError ,URLErrorfrom bs4 import BeautifulSoup#打开urlhtml = urlopen("http://www.pythonscraping.com/pages/page3.html")原创 2018-01-14 15:51:04 · 270 阅读 · 0 评论 -
python-(beautifulsoup)爬虫-3
刚刚学习了beautifulsoup,就想自己练练手,写的不是很好,也参考了网上一些写法。 主要是爬取天天基金上的基金的涨跌比。from urllib.request import urlopenfrom urllib.parse import urlparsefrom bs4 import BeautifulSoupimport re import csvfrom itertoo原创 2018-01-17 08:51:40 · 283 阅读 · 0 评论 -
python-常见问题记录
1.查看已经按照的包 pip list 在python 环境下面执行 help(‘modules’)2.电脑里共存py2和py3 安装了anaconda 2 和3 将anaconda3 中的 python.exe 改为了 python3.exe 安装包的时候 执行python3 -m pip install bs4 运行的时候 python3 *.py原创 2018-01-14 15:00:31 · 214 阅读 · 0 评论