urllib库安装

先切换到pip所在目录

D:\Program Files\JetBrains\PyCharm 2017.3.3\untitled>cd /d c:\

c:\>cd c:\Users\ceshi\AppData\Local\Programs\Python\Python36\Scripts\

执行下载安装指令【哦 这里装了个exe打包工具 要装urllib的话 直接把名字改了就成

c:\Users\ceshi\AppData\Local\Programs\Python\Python36\Scripts>pip install Pyinstaller

以下是打包exe的,与urllib无关

c:\Users\ceshi\AppData\Local\Programs\Python\Python36\Scripts>pyinstaller.exe -F d:\pytest\gai.py

=============================================

课文内容待补

====================================

回来了。。

要被这节课搞疯  python2和python3的鸿沟 对于刚入门的小辣鸡来说实在是。。 心疼自己(ಥ_ಥ)

装的是python3.6.4

 1 import random
2 from urllib import request     #from urllib import urlopen
3 import sys
4
5 WORD_URL = "http://learncodethehardway.org/words.txt"
6 WORDS = []
7
8 PHRASES = {
9 "class %%%(%%%):":
10 "Make a class named %%% that is-a %%%.",
11 "class %%%(object):\n\tdef __init__(self, ***)" :
12 "class %%% has-a __init__ that takes seulf and *** parameters.",
13 "class %%%(object):\n\tdef ***(self, @@@)":
14 "class %%% has-a function named *** that takes self and @@@ parameters.",
15 "*** = %%%()":
16 "Set *** to an instance of class %%%.",
17 "***.***(@@@)":
18 "From *** get the *** function, and call it with parameters self, @@@.",
19 "***.*** = '***'":
20 "From *** get the *** attribute and set it to '***'."
21 }
22
23 # do they want to drill phrases first
24 if len(sys.argv) == 2 and sys.argv[1] == "english":
25 PHRASE_FIRST = True
26 else:
27 PHRASE_FIRST = False
28
29 # load up the words from the website
30 for word in request.urlopen(WORD_URL).readlines():     #for word in urlopen(WORD_URL).readlines():
31 WORDS.append(word.strip())
32
33 def convert(snippet, phrase):
34 class_names = [w.capitalize() for w in
35 random.sample(WORDS, snippet.count("%%%"))]
36 other_names = random.sample(WORDS, snippet.count("***"))
37 results = []
38 param_names = []
39
40 for i in range(0, snippet.count("@@@")):
41 param_count = random.randint(1,3)
42 param_names.append(', '.join(str(random.sample(WORDS, param_count))))    #param_names.append(', '.join(random.sample(WORDS, param_count)))
43
44 for sentence in snippet, phrase:
45 result = sentence[:]
46
47 # fake class names
48 for word in class_names:
49 result = result.replace("%%%", "word", 1)      #result = result.replace("%%%", word, 1)
50
51 # fake other names
52 for word in other_names:
53 result = result.replace("***", "word", 1)      #result = result.replace("***", word, 1)
54
55 # fake parameter lists
56 for word in param_names:
57 result = result.replace("@@@", word, 1)
58
59 results.append(result)
60
61 return results
62
63 # keep going until they hit CTRL-D
64 try:
65 while True:
66 snippets = list(PHRASES.keys())
67 random.shuffle(snippets)
68
69 for snippet in snippets:
70 phrase = PHRASES[snippet]
71 question, answer = convert(snippet, phrase)
72 if PHRASE_FIRST:
73 question, answer = answer, question
74
75 print(question)
76
77 input("> ")
78 print("ANSWER: %s\n\n" % answer)
79 except EOFError:
80 print("\nBye")

========================

绕得晕乎乎。。 最近转做发行运营公司的测试。 感觉原本仅存的脑子也被吃掉了 写在小本本上背吧。。

在左边有一个Python代码片段列表,右面是他们的解释

class X(Y):创建一个叫X的类,并继承Y

class X(object): def __init__(self, J):类X有一个__init__方法,该方法有self和J两个参数

class X(object): def M(self, J):类X有一个叫M的函数,该函数有self和J两个参数

foo = X():给foo赋值为类X的一个实例

foo.M(J):从foo里调用M函数,传递的参数为self和J

foo.K = Q:从foo里调用K属性,并将其设置为Q。

笨办法41学会说面向对象【pyinstaller安装使用的更多相关文章

  1. sql笨办法同步数据

    Helpers.SqlHelper sqlHelper = new Helpers.SqlHelper("server=***;database=Cms;user id=sa;passwor ...

  2. 笨办法用js屏蔽被http劫持的浮动广告

    最近发现网站经常在右下角弹出一个浮动广告,开始的时候以为只是浏览器的广告. 后来越来越多同事反映在家里不同浏览器也会出现广告.然后深入检查了下,发现网站竟然被劫持了. 然后百度了一大堆资料,什么htt ...

  3. Atom 安装 Packages 的笨办法

    在终端里输入下面的命令打开 Atom 的 packages 的安装目录. open ~/.atom/packages 然后找到需要安装的 Atom packages ,比如我需要安装的这个 atom- ...

  4. PyInstaller 安装方法 及简单的编译exe (python3)

    安装PyInstaller //地址 https://github.com/pyinstaller/pyinstaller/tree/python3 //上面的链接已经失效,新的(20160809更) ...

  5. 【PyInstaller安装及使用】将py程序转换成exe可执行程序

    1  配置所需的环境 平台:windows7 64位,已经安装了python(x,y) 若未安装python环境,请自行安装python2.7或者其他版本,Python安装完成以后,需要将Python ...

  6. PyInstaller安装使用方法

    PyInstaller可以把Python应用程序及其所有依赖项捆绑到一个包中.用户可以在不安装Python解释器或任何模块的情况下运行打包的应用程序.PyInstaller支持Python 2.7和P ...

  7. pyinstaller安装配置

    一.工具准备: 1).安装pyinstaller需要以这个包为基础.也就是基础软件包.pyWin32包.下载对应的pyWin32安装包>>地址: https://sourceforge.n ...

  8. Pyinstaller安装以及参数使用

    一.安装 pip install pyinstaller (注:win7系统安装有pywin32依赖包,先按pywin32在进行以上的步骤) 二.参数说明(这里要注意大小写) -F   表示生成单个可 ...

  9. pyinstaller安装及使用

    pyinstaller使用 将.py文件转换成无需源码的.exe可执行文件 下载 1.打开cmd直接输入pip install pyinstaller即可下载 2.如第一种方法无法下载,打开pyins ...

随机推荐

  1. Prometheus监控学习笔记之Prometheus的Relabel,SD以及Federation功能

    0x00 k8s 的监控设计 k8s 默认以及推荐的监控体系是它自己的一套东西:Heapster + cAdvisor + Influxdb + Grafana,具体可以看 这里 . 包括 k8s 自 ...

  2. 在ubuntu的bash中循环执行脚本,并在内存不足时重启

    #!/bin/bash date ma=`grep MemAvailable /proc/meminfo | awk '{print $2}'` echo MemAvailable = $ma run ...

  3. 51nod1363 最小公倍数之和

    题目描述 给出一个n,求1-n这n个数,同n的最小公倍数的和. 例如:n = 6,1,2,3,4,5,6 同6的最小公倍数分别为6,6,6,12,30,6,加在一起 = 66. 由于结果很大,输出Mo ...

  4. 容器中的诊断与分析3——live diagnosis——lldb

    windows下,我们对于.net程序发生Crash,资源泄露,死锁等问题的分析,有神器windbg .net core程序运行在linux上时,该怎么进行对对Core Dump文件进行分析呢?今天介 ...

  5. python学习之旅(入门)

    一.list 有序集合 1.list 有序集合  L = [95.5, 85, 59]  如L[1] = 85 ,L[-1] = 59  和php中array一个意思  用[] 表示就可以了 2.新增 ...

  6. 兼容ie8的前端下载方法

    背景:在xp系统上 ie8浏览器的下载需求,后端返回资源路径. 方法:谷歌下采用aDown下载,ie采用window.open 触发下载,如果不能自动自动下载,采用execCommand(" ...

  7. 详细分析Java中断机制-转载

    1. 引言 当我们点击某个杀毒软件的取消按钮来停止查杀病毒时,当我们在控制台敲入quit命令以结束某个后台服务时……都需要通过一个线程去取消另一个线程正在执行的任务.Java没有提供一种安全直接的方法 ...

  8. Unity---在Hierarchy视图中将选中的对象的层级目录复制到剪切板

    using UnityEditor; using UnityEngine; public class ObjPathCopyTool : ScriptableObject { [MenuItem(&q ...

  9. 2 - Binary Search & LogN Algorithm

    254. Drop Eggs https://www.lintcode.com/problem/drop-eggs/description?_from=ladder&&fromId=1 ...

  10. springboot junit

    1 添加pom依赖 <dependency> <groupId>org.springframework.boot</groupId> <artifactId& ...