笨方法学python3
CheneyTAT
这个作者很懒,什么都没留下…
展开
-
pytorch深度学习实战——预训练网络
from torchvision import models from torchvision import transforms from PIL import Image import torch dir(models) alexnet = models.AlexNet() resnet = models.resnet101(pretrained=True) resnet preprocess = transforms.Compose([ transforms.Resize(256), .原创 2022-03-20 19:08:45 · 2984 阅读 · 0 评论 -
【终于看懂了】笨办法学python——习题41
import random from urllib.request import urlopen import sys WORD_URL = "http://learncodethehardway.org/words.txt" WORDS = [] PHRASES = { "class %%%(%%%):": "Make a class named %%% that is-a %%%.", "class %%%(object): \n\t def __init__(se.原创 2022-03-19 17:02:19 · 484 阅读 · 0 评论 -
笨办法学python3——习题40
class Song(object): def __init__(self, lyrics): self.lyrics = lyrics def sing_me_a_song(self): for line in self.lyrics: print(line) happy_bday = Song(["Happy Birthday to you", "I don't want to get.原创 2022-03-19 11:31:27 · 259 阅读 · 0 评论 -
笨办法学python3——习题39
# create a mapping of state to abbreviation states = { 'Oregon': 'OR', 'Florida': 'FL', 'California': 'CA', 'New York': 'NY', 'Michigan': 'MI' } # create a basic set of states and some cities in them cities = { 'CA': 'San Francisc.原创 2022-03-18 15:26:59 · 224 阅读 · 0 评论 -
笨办法学python3——习题38
ten_things = "Apples Oranges Crows Telephone Light Sugar" print("Wait there are not 10 things in that list. Let's fix that.") stuff = ten_things.split(' ') more_stuff = ["Day", "Night", "Song", "Frisbee", "Corn", "Banana", "Girl", "Boy"] .原创 2022-03-17 16:37:40 · 586 阅读 · 0 评论 -
笨办法学python——习题35
from sys import exit def gold_room(): print("This room is full of gold. How much do you take?") choice = input(">") if "0" in choice or "1" in choice: how_much = int(choice) else: dead("Man, learn to type a number.") .原创 2022-03-17 13:13:08 · 133 阅读 · 0 评论 -
笨办法学python3——习题33
def whileloop(top, stop, step): i = 0 numbers = [] for i in range(top, stop, step): print(f"At the top of i is {i}") numbers.append(i) i += 1 print("Numbers now: ", numbers) print(f"At the bottom i is .原创 2022-03-16 11:11:38 · 456 阅读 · 0 评论 -
笨办法学python3——习题32
the_count = [1, 2, 3, 4, 5] fruits = ['apples', 'oranges', 'pears', 'apricots'] change = [1, 'pennies', 2, 'dimes', 3, 'quarters'] # this first kind of for-loop goes through a list for number in the_count: print(f"This is count {number}") # same as .原创 2022-03-15 12:13:55 · 353 阅读 · 0 评论 -
笨办法学python3——习题25
def break_words(stuff): """ This function will break up words for us.""" words = stuff.split('') return words def sort_words(words): """Sorts the words.""" return sorted(words) def print_first_word(words): """Prints the first wor.原创 2022-03-15 10:04:26 · 122 阅读 · 0 评论 -
笨办法学python3——习题23注释
import sys script, encoding, error = sys.argv # argv用于输入参数 def main(language_file, encoding, errors): line = language_file.readline() # 从给它的语言文件中读取一行,用readline处理文本文件 # 以下if结构用来检查文件是否结束,运行到文件结尾会返回空字符串,则此处为真,if后面的代码可以执行 if line: # 防止一直循环下去 .原创 2022-03-13 15:17:31 · 325 阅读 · 1 评论