python --- 函数学习的准备

来源:互联网 发布:金10数据官网财经日历 编辑:程序博客网 时间:2024/06/06 06:35

1 有关同学阿玲的game习题

2 语句即逻辑,结构即存储
if
while :
pass

for

数据结构:
dict
list
tuple

到固定地址获取数据思路步骤:

#geturl http://www.126.com#获取数据 urllib2    #1.访问网页         #访问不成功(log)         #访问成功    #2.#分析数据 正则 和 beautifulsoup#入库

3 virtualenv的使用
python的沙盒环境,参考http://www.cnblogs.com/zknublx/p/5953249.html

root@kali:~/python/laowangpy# pip install https://github.com/pypa/virtualenv/tarball/masterDownloading/unpacking https://github.com/pypa/virtualenv/tarball/master  Downloading master (unknown size): 1.9Mb downloaded  Running setup.py egg_info for package from https://github.com/pypa/virtualenv/tarball/master    warning: no previously-included files matching '*' found under directory 'docs/_templates'    warning: no previously-included files matching '*' found under directory 'docs/_build'Installing collected packages: virtualenv  Running setup.py install for virtualenv    warning: no previously-included files matching '*' found under directory 'docs/_templates'    warning: no previously-included files matching '*' found under directory 'docs/_build'    Installing virtualenv script to /usr/local/binSuccessfully installed virtualenvCleaning up...root@kali:~/python/laowangpy# lsa.txt         geshihua.py   logid.txt      print_test.py   searchzimu.py  test2.txt              zimuchange.pybeiscount.py  hello.py      memid.txt      print_test.txt  sortdaxiao.py  test_def_info_list.pydatadig       idsearch.py   nocount.py     _project        sortzimu2.py   test_def_info.pydef1.py       id.txt        print1.py      result.txt      sortzimu.py    test_uncode.pydictserch.py  list_demo.py  print_cont.py  searchzimu2.py  test1.txt      withtest.pyroot@kali:~/python/laowangpy# virtualenv pytest1_envNew python executable in /root/python/laowangpy/pytest1_env/bin/pythonInstalling setuptools, pip, wheel...done.root@kali:~/python/laowangpy# lsa.txt         geshihua.py   logid.txt      print_test.py   searchzimu2.py  test1.txt              withtest.pybeiscount.py  hello.py      memid.txt      print_test.txt  searchzimu.py   test2.txt              zimuchange.pydatadig       idsearch.py   nocount.py     _project        sortdaxiao.py   test_def_info_list.pydef1.py       id.txt        print1.py      pytest1_env     sortzimu2.py    test_def_info.pydictserch.py  list_demo.py  print_cont.py  result.txt      sortzimu.py     test_uncode.pyroot@kali:~/python/laowangpy# virtualenv pytest2_envNew python executable in /root/python/laowangpy/pytest2_env/bin/pythonInstalling setuptools, pip, wheel...done.root@kali:~/python/laowangpy# lsa.txt         geshihua.py   logid.txt      print_test.py   result.txt      sortzimu.py            test_uncode.pybeiscount.py  hello.py      memid.txt      print_test.txt  searchzimu2.py  test1.txt              withtest.pydatadig       idsearch.py   nocount.py     _project        searchzimu.py   test2.txt              zimuchange.pydef1.py       id.txt        print1.py      pytest1_env     sortdaxiao.py   test_def_info_list.pydictserch.py  list_demo.py  print_cont.py  pytest2_env     sortzimu2.py    test_def_info.pyroot@kali:~/python/laowangpy# cd pytest1_env/root@kali:~/python/laowangpy/pytest1_env# lsbin  include  lib  local  pip-selfcheck.jsonroot@kali:~/python/laowangpy/pytest1_env# source ./bin/activate(pytest1_env) root@kali:~/python/laowangpy/pytest1_env# pip install requestsCollecting requests/root/python/laowangpy/pytest1_env/local/lib/python2.7/site-packages/pip/_vendor/requests/packages/urllib3/util/ssl_.py:318: SNIMissingWarning: An HTTPS request has been made, but the SNI (Subject Name Indication) extension to TLS is not available on this platform. This may cause the server to present an incorrect TLS certificate, which can cause validation failures. You can upgrade to a newer version of Python to solve this. For more information, see https://urllib3.readthedocs.io/en/latest/security.html#snimissingwarning.  SNIMissingWarning/root/python/laowangpy/pytest1_env/local/lib/python2.7/site-packages/pip/_vendor/requests/packages/urllib3/util/ssl_.py:122: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. You can upgrade to a newer version of Python to solve this. For more information, see https://urllib3.readthedocs.io/en/latest/security.html#insecureplatformwarning.  InsecurePlatformWarning  Downloading requests-2.18.4-py2.py3-none-any.whl (88kB)    100% |████████████████████████████████| 92kB 225kB/s Collecting urllib3<1.23,>=1.21.1 (from requests)  Downloading urllib3-1.22-py2.py3-none-any.whl (132kB)    100% |████████████████████████████████| 133kB 179kB/s Collecting idna<2.7,>=2.5 (from requests)  Downloading idna-2.6-py2.py3-none-any.whl (56kB)    100% |████████████████████████████████| 61kB 152kB/s Collecting chardet<3.1.0,>=3.0.2 (from requests)  Downloading chardet-3.0.4-py2.py3-none-any.whl (133kB)    100% |████████████████████████████████| 143kB 162kB/s Collecting certifi>=2017.4.17 (from requests)  Downloading certifi-2017.7.27.1-py2.py3-none-any.whl (349kB)    100% |████████████████████████████████| 358kB 118kB/s Installing collected packages: urllib3, idna, chardet, certifi, requestsSuccessfully installed certifi-2017.7.27.1 chardet-3.0.4 idna-2.6 requests-2.18.4 urllib3-1.22(pytest1_env) root@kali:~/python/laowangpy/pytest1_env# pythonPython 2.7.3 (default, Mar 14 2014, 11:57:14) [GCC 4.7.2] on linux2Type "help", "copyright", "credits" or "license" for more information.>>> import requests>>> response = requests.get("http://www.baidu.com")>>> response.status_code200>>> exit()(pytest1_env) root@kali:~/python/laowangpy/pytest1_env# pip list#沙盒pytest1_env安装的软件DEPRECATION: The default format will switch to columns in the future. You can use --format=(legacy|columns) (or define a format=(legacy|columns) in your pip.conf under the [list] section) to disable this warning.certifi (2017.7.27.1)chardet (3.0.4)idna (2.6)pip (9.0.1)requests (2.18.4)setuptools (36.6.0)urllib3 (1.22)wheel (0.30.0)(pytest1_env) root@kali:~/python/laowangpy/pytest1_env# (pytest1_env) root@kali:~/python/laowangpy/pytest1_env# deactivate#退出沙盒root@kali:~/python/laowangpy/pytest1_env# 

4 推荐参考书
基础书籍:
1).程序员数学
2).大话数据结构 大话设计模式
3).C语音(销量最好的书)

进阶书籍:
1).python标准库
2).python基础教程
3).docs.python.org官方文档
4).啄木鸟社区的邮件列表