python --- 函数学习的准备

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/master
Downloading/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/bin
Successfully installed virtualenv
Cleaning up...
root@kali:~/python/laowangpy# ls
a.txt         geshihua.py   logid.txt      print_test.py   searchzimu.py  test2.txt              zimuchange.py
beiscount.py  hello.py      memid.txt      print_test.txt  sortdaxiao.py  test_def_info_list.py
datadig       idsearch.py   nocount.py     _project        sortzimu2.py   test_def_info.py
def1.py       id.txt        print1.py      result.txt      sortzimu.py    test_uncode.py
dictserch.py  list_demo.py  print_cont.py  searchzimu2.py  test1.txt      withtest.py
root@kali:~/python/laowangpy# virtualenv pytest1_env
New python executable in /root/python/laowangpy/pytest1_env/bin/python
Installing setuptools, pip, wheel...done.
root@kali:~/python/laowangpy# ls
a.txt         geshihua.py   logid.txt      print_test.py   searchzimu2.py  test1.txt              withtest.py
beiscount.py  hello.py      memid.txt      print_test.txt  searchzimu.py   test2.txt              zimuchange.py
datadig       idsearch.py   nocount.py     _project        sortdaxiao.py   test_def_info_list.py
def1.py       id.txt        print1.py      pytest1_env     sortzimu2.py    test_def_info.py
dictserch.py  list_demo.py  print_cont.py  result.txt      sortzimu.py     test_uncode.py
root@kali:~/python/laowangpy# virtualenv pytest2_env
New python executable in /root/python/laowangpy/pytest2_env/bin/python
Installing setuptools, pip, wheel...done.
root@kali:~/python/laowangpy# ls
a.txt         geshihua.py   logid.txt      print_test.py   result.txt      sortzimu.py            test_uncode.py
beiscount.py  hello.py      memid.txt      print_test.txt  searchzimu2.py  test1.txt              withtest.py
datadig       idsearch.py   nocount.py     _project        searchzimu.py   test2.txt              zimuchange.py
def1.py       id.txt        print1.py      pytest1_env     sortdaxiao.py   test_def_info_list.py
dictserch.py  list_demo.py  print_cont.py  pytest2_env     sortzimu2.py    test_def_info.py
root@kali:~/python/laowangpy# cd pytest1_env/
root@kali:~/python/laowangpy/pytest1_env# ls
bin  include  lib  local  pip-selfcheck.json
root@kali:~/python/laowangpy/pytest1_env# source ./bin/activate
(pytest1_env) root@kali:~/python/laowangpy/pytest1_env# pip install requests
Collecting 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, requests
Successfully 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# python
Python 2.7.3 (default, Mar 14 2014, 11:57:14) 
[GCC 4.7.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import requests
>>> response = requests.get("http://www.baidu.com")
>>> response.status_code
200
>>> 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).啄木鸟社区的邮件列表

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

徐为波

看着给就好了,学习写作有点累!

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值