随笔分类 -  python

摘要:非常简单 可以很快的上手 官网:https://dormousehole.readthedocs.io/en/latest/index.html#id3 from flask import Flask, request, jsonify import json app = Flask(__name_ 阅读全文
posted @ 2021-06-30 10:31 野兽Gentleman 阅读(73) 评论(0) 推荐(0)
摘要:目前来看不是很喜欢这个语言 依靠缩进判断逻辑目前来说不适应 目前书里面只讲了继承,但是对于实现貌似没有这个概念 类中随意的定义属性使我非常的恼火 感觉很不规范 如果有其他语言基础的话不推荐这本书去学python 总体感觉可能是刚刚入门 期待下一步的学习 ps:后面python web Django没 阅读全文
posted @ 2021-04-24 13:50 野兽Gentleman 阅读(382) 评论(0) 推荐(0)
摘要:import requests # 执行API调用并存储响应 url = 'https://api.github.com/search/repositories?q=language:python&sort=stars' headers = {'Accept': 'application/vnd.g 阅读全文
posted @ 2021-04-24 13:40 野兽Gentleman 阅读(127) 评论(0) 推荐(0)
摘要:import csv from datetime import datetime from matplotlib import pyplot as plt filename = 'data/sitka_weather_2018_simple.csv' with open(filename) as f 阅读全文
posted @ 2021-04-24 13:25 野兽Gentleman 阅读(95) 评论(0) 推荐(0)
摘要:写到后面有点恶心,python这个语言还是很不适应 就不挨个贴代码了,有兴趣的可以下载看一下 下载 https://files.cnblogs.com/files/beastGentleman/t13.zip 阅读全文
posted @ 2021-04-21 10:31 野兽Gentleman 阅读(52) 评论(0) 推荐(0)
摘要:我是python版本3.8.8 不是python3的话自己去找一下python的安装语句pip3 install matplotlib 安装命令切记多试几次! pip3 install matplotlib -i https://pypi.tuna.tsinghua.edu.cn/simple如果上 阅读全文
posted @ 2021-04-17 14:00 野兽Gentleman 阅读(97) 评论(0) 推荐(0)
摘要:import sys import pygame from settings import Settings from ship import Ship from bullet import Bullet class AlienInvasion: "管理游戏资源和行为的类" def __init__ 阅读全文
posted @ 2021-04-17 13:23 野兽Gentleman 阅读(92) 评论(0) 推荐(0)
摘要:filename = 'pi_digits.txt' with open(filename) as file_object: lines = file_object.readlines() for line in lines: print(line.rstrip()) open() 接受的参数是当前 阅读全文
posted @ 2021-04-11 16:14 野兽Gentleman 阅读(100) 评论(0) 推荐(0)
摘要:class Dog: """A simple attempt to model a dog.""" def __init__(self, name, age): """Initialize name and age attributes.""" self.name = name self.age = 阅读全文
posted @ 2021-04-11 15:35 野兽Gentleman 阅读(62) 评论(0) 推荐(0)
摘要:def getUser(): def关键字定义了一个函数 关键字实参 def getUser(userName, userAge): getUser(userName='张三', userAge=18) 默认值 def getUser(userName, userAge=18): 如果没有传年龄过来 阅读全文
posted @ 2021-04-11 14:56 野兽Gentleman 阅读(159) 评论(0) 推荐(0)
摘要:input() 可以添加参数显示在控制台 然后获得输入的字符串 int()获得输入的数字 求模运算 4%3 -- 15%3 -- 2 6%3 -- 0 阅读全文
posted @ 2021-04-11 14:19 野兽Gentleman 阅读(62) 评论(0) 推荐(0)
摘要:字典 alien_0 = {'x_position': 0, 'y_position': 25, 'speed': 'medium'} print(f"Original position: {alien_0['x_position']}") Original position: 0 字典是键值对 感 阅读全文
posted @ 2021-04-11 14:08 野兽Gentleman 阅读(76) 评论(0) 推荐(0)
摘要:cars = ['audi', 'bmw', 'subaru', 'toyota'] for car in cars: if car == 'bmw': print(car.upper()) else: print(car.title()) if语句 得到的值是Treu 或者 False 注意首字母 阅读全文
posted @ 2021-04-11 13:35 野兽Gentleman 阅读(51) 评论(0) 推荐(0)
摘要:1 magicians = ['alice', 'david', 'carolina'] 2 for magician in magicians: 3 print(f"{magician.title()}, that was a great trick!") 4 print(f"I can't wa 阅读全文
posted @ 2021-04-11 13:25 野兽Gentleman 阅读(117) 评论(0) 推荐(0)
摘要:1 bicycles = ['trek', 'cannondale', 'redline', 'specialized', 'remove'] 2 print(bicycles) 3 print(bicycles[0]) 4 print(bicycles[0].title()) 5 print(bi 阅读全文
posted @ 2021-04-06 21:33 野兽Gentleman 阅读(54) 评论(0) 推荐(0)
摘要:1 first_name = "ada" 2 last_name = "lovelace" 3 # f可以替换里面的内容 f字符串是python3.6引入的 full_name = “{}{}”.format(a,b) 4 5 full_name = f"{first_name}-{last_nam 阅读全文
posted @ 2021-04-06 21:11 野兽Gentleman 阅读(67) 评论(0) 推荐(0)