jcyrss / baiyueheiyu

教程官网地址 www.byhy.net
4 stars 1 forks source link

无影暗魔宗 #6

Open jcyrss opened 4 years ago

jcyrss commented 4 years ago

vscode 的 配置 settings.json

{
    "workbench.settings.openDefaultKeybindings":true,
    "workbench.view.experimental.allowMovingToNewContainer":true,
    "terminal.integrated.shell.windows": "C:\\Windows\\System32\\cmd.exe",
    "git.autofetch": true,
    "git.enableSmartCommit": true,
    "files.autoSave": "afterDelay",
    "editor.fontSize": 15,
    "workbench.sideBar.location": "left",
    "workbench.startupEditor": "newUntitledFile",
    "gitlens.codeLens.authors.enabled": false,
    "gitlens.hovers.annotations.changes": false,
    "gitlens.hovers.currentLine.changes": false,
    "gitlens.hovers.annotations.details": false,
    "gitlens.hovers.annotations.enabled": false,
    "gitlens.showWhatsNewAfterUpgrades": false,
    "eslint.enable": false,
    "[python]": {
        "editor.insertSpaces": true,
        "editor.tabSize": 4  
      },
    "gitlens.advanced.messages": {
      "suppressSupportGitLensNotification": true
    },
    "python.jediEnabled": false,
    "window.zoomLevel": 0,
    "explorer.confirmDelete": false,
    "files.eol": "\n",
    "gitlens.gitCommands.skipConfirmations": [
      "fetch:command",
      "stash-push:command",
      "switch:command",
      "push:command"
    ],
    "gitlens.gitCommands.closeOnFocusOut": true,
    "gitlens.currentLine.enabled": false,
    "gitlens.hovers.enabled": false,
    "markdown-toc.updateOnSave": false,
    "editor.fontFamily": "Consolas, 'Courier New', monospace, '微软雅黑'",
    "editor.accessibilitySupport": "off",
    "diffEditor.ignoreTrimWhitespace": false,
    "workbench.preferredDarkColorTheme": "GitHub Plus",
    "workbench.preferredHighContrastColorTheme": "GitHub Plus",
    "workbench.preferredLightColorTheme": "GitHub Plus",

    "http.proxy": "http://127.0.0.1:10800",

    // https://code.visualstudio.com/api/extension-guides/color-theme#workbench-colors
    "workbench.colorCustomizations": {
      "[GitHub Plus]": {
        // activity bar
        "activityBar.border": "#e9e1e1",
        "activityBar.background": "#ffffff",
        "activityBar.foreground": "#c72160",
        "activityBar.inactiveForeground": "#4b94b6",
        "activityBarBadge.background": "#d73a49",
        // sideBar bar
        "sideBar.border": "#e7e4e4",
        "sideBar.background": "#ffffff",
        "sideBar.foreground": "#000000",
        "sideBarSectionHeader.background": "#ffffff",            
        "sideBarSectionHeader.border": "#e1e1e6", 

        "editorLineNumber.foreground": "#4d5f3c",

      }
    },
    "editor.mouseWheelZoom": true,
    "workbench.colorTheme": "GitHub Plus",

    // https://stackoverflow.com/a/57426933/2602410
    "editor.tokenColorCustomizations": {
      "[GitHub Plus]": {
        "textMateRules": [
        {
              "scope": [
                "entity.name.type.class",
                "entity.other.inherited-class"
              ],
              "settings": {
                  "foreground": "#296fb6",
                  "fontStyle": "bold"
              }
        },
        {
          "scope": [
              "meta.definition.method"
          ],
          "settings": {
              "foreground": "#2871bb",
              "fontStyle": "underline"
          }
        },
        {
            "scope": [
              "meta.object-literal.key",
              "variable.other.property"
            ],
            "settings": {
                "foreground": "#296fb6",
            }
        },
        {
            "scope": [
              "variable.parameter"
            ],
            "settings": {
                "foreground": "#b629a3",
                "fontStyle": "italic"
            }
        },
        {
            "scope": [
              // "variable.parameter",
              "variable.other.readwrite",
              "meta.arrow.js"
            ],
            "settings": {
                "foreground": "#06172b"
            }
        },

        {
            "scope": [
                "meta.function-call",
                "entity.name.function"
            ],
            "settings": {
                "foreground": "#2871bb"
            }
        }

      ]

      }
    }

}
jcyrss commented 4 years ago

vscode 快捷键配置

// Place your key bindings in this file to override the defaults
[
    {
        "key": "ctrl+1",
        "command": "editor.action.insertSnippet",
        "when": "editorTextFocus",
        "args": {
            "langId": "markdown",
            "snippet": " `$TM_SELECTED_TEXT$0` "
        }
    },
    {
        "key": "ctrl+2",
        "command": "editor.action.insertSnippet",
        "when": "editorTextFocus",
        "args": {
            "langId": "markdown",
            "snippet": "```py\n$TM_SELECTED_TEXT$0\n```"
        }
    },
    {
        "key": "ctrl+3",
        "command": "editor.action.insertSnippet",
        "when": "editorTextFocus",
        "args": {
            "langId": "markdown",
            "snippet": "<br>"
        }
    },
    {
        "key": "ctrl+4",
        "command": "editor.action.insertSnippet",
        "when": "editorTextFocus",
        "args": {
            "langId": "markdown",
            "snippet": "<hr>"
        }
    },
    {
        "key": "ctrl+b",
        "command": "editor.action.insertSnippet",
        "when": "editorTextFocus",
        "args": {
            "langId": "markdown",
            "snippet": " **$TM_SELECTED_TEXT** "
        }
    },        
    {
        "key": "ctrl+shift+u",
        "command": "editor.action.transformToUppercase",
        "when": "editorTextFocus"
    },
    {
        "key": "ctrl+shift+l",
        "command": "editor.action.transformToLowercase",
        "when": "editorTextFocus"
    },

    {
        "key": "ctrl+l",
        "command": "editor.action.insertSnippet",
        "when": "editorTextFocus",
        "args": {
            "langId": "markdown",
            "snippet": "<a href='$CLIPBOARD' target='_blank'>$TM_SELECTED_TEXT</a>"
        }
    },
    {
        "key": "ctrl+n",
        "command": "editor.action.insertSnippet",
        "when": "editorTextFocus",
        "args": {
            "langId": "markdown",
            "snippet": "<div class='alert alert-note'><div>\n$TM_SELECTED_TEXT\n</div></div>"
        }
    },
    {
        "key": "ctrl+alt+n",
        "command": "editor.action.insertSnippet",
        "when": "editorTextFocus",
        "args": {
            "langId": "markdown",
            "snippet": "<p class='notice--info'>\n$TM_SELECTED_TEXT\n</p>"
        }
    },
    {
        "key": "ctrl+shift+i",
        "command": "editor.action.insertSnippet",
        "when": "editorTextFocus",
        "args": {
            "langId": "markdown",
            "snippet": "![image]($TM_SELECTED_TEXT)"
        }
    },
    {
        "key": "ctrl+oem_7",
        "command": "cursorLineEnd"
    },
    {
        "key": "f9",
        "command": "toggleVim"
    },
    {
        "key": "alt+1",
        "command": "editor.action.insertSnippet",
        "when": "editorTextFocus",
        "args": {
            "langId": "markdown",
            "snippet": "```html\n$TM_SELECTED_TEXT$0\n```"
        }
    },
    {
        "key": "alt+2",
        "command": "editor.action.insertSnippet",
        "when": "editorTextFocus",
        "args": {
            "langId": "markdown",
            "snippet": "```css\n$TM_SELECTED_TEXT$0\n```"
        }
    },
    {
        "key": "alt+3",
        "command": "editor.action.insertSnippet",
        "when": "editorTextFocus",
        "args": {
            "langId": "markdown",
            "snippet": "```js\n$TM_SELECTED_TEXT$0\n```"
        }
    },
    {
        "key": "alt+4",
        "command": "editor.action.insertSnippet",
        "when": "editorTextFocus",
        "args": {
            "langId": "markdown",
            "snippet": "\n\n<iframe style='width: 100%;border: none;background: #fbfbfb;' \n onload='javascript:(function(o){o.style.height=o.contentWindow.document.body.scrollHeight+20+\"px\";}(this));'\n srcdoc='\n\n'>\n</iframe>\n\n"
        }
    },
    {
        "key": "alt+5",
        "command": "editor.action.insertSnippet",
        "when": "editorTextFocus",
        "args": {
            "langId": "markdown",
            "snippet": "\n{{< htmlpg frameHeight=\"10rem\">}}\n```html\n$TM_SELECTED_TEXT$0\n```\n{{< /htmlpg >}}"
        }
    },
    {
        "key": "alt+f",
        "command": "editor.action.insertSnippet",
        "when": "editorTextFocus",
        "args": {
            "langId": "markdown",
            "snippet": "\n\n{{% forsites my %}}\n<div style='margin:1em 0;padding:.2em;border:1px solid #cdc'>\n\n$TM_SELECTED_TEXT$0\n\n</div>\n{{% /forsites %}}\n\n"
        }
    },

]
jcyrss commented 4 years ago

在线教育系统需求.docx

jcyrss commented 4 years ago

学员写的

listnum = '零壹贰叁肆伍陆柒捌玖'
def convert4digits(num):
    if len(num)==1:
        newnum = listnum[int(num)]
        print(newnum)
    elif len(num)==2:
        newnum = listnum[int(num[0])]+'拾'+listnum[int(num[1])]
        newnum = newnum.replace('拾零','拾')
        print(newnum)
    elif len(num)==3:
        newnum = listnum[int(num[0])]+'佰'+listnum[int(num[1])]+'拾'+listnum[int(num[2])]
        newnum = newnum.replace('零拾','零')
        newnum = newnum.replace('拾零', '拾')
        newnum = newnum.replace('零拾零','')
        print(newnum)
    elif len(num)==4:
        newnum = listnum[int(num[0])]+'仟'+listnum[int(num[1])]+'佰'+listnum[int(num[2])]+'拾'+listnum[int(num[3])]
        newnum = newnum.replace('零佰','零')
        newnum = newnum.replace('零拾','零')
        newnum = newnum.replace('零零', '零')
        newnum = newnum.replace('拾零', '拾')
        newnum = newnum.replace('零佰零拾','零')
        newnum = newnum.replace('零佰零拾零','')
        print(newnum)
    elif len(num)>4:
        print('数字最多是4位')
convert4digits('4')
convert4digits('14')
convert4digits('40')
convert4digits('340')
convert4digits('1004')
convert4digits('1234')
convert4digits('10040')


学员写的最好的

def convert4digits(num):
    if len(str(num)) > 10:
        print('数字最多是4位')
        return
    d = ['零','壹','贰','叁','肆','伍','陆','柒','捌','玖']
    w = ['','拾','佰','仟','万']
    b = ''
    for each,i in zip(reversed(str(num)),range(4)):
        print(each,i)
        if b == '' and int(each) == 0:
            continue
        if int(each) == 0 and b[0] != '零':
            b = '零' + b
        elif int(each) == 0 :
            continue
        else:
            b = d[int(each)] + w[i] +b
    print(b)
convert4digits('14')
convert4digits('40')
convert4digits('340')
convert4digits('1004')
convert4digits('1234')
convert4digits('10040')


我写的

lowerChars = '1234567890'
upChars    = '壹贰叁肆伍陆柒捌玖零'

inNum = input('请输入数字金额:')
if not inNum.isdigit():
    print('请输入全数字')
    exit()

# 获取阿拉伯数字对应的 汉字大写
def getNum(ch):
    index = lowerChars.find(ch)
    return upChars[index]

def convert4digits(num4c):
    numLen = len(num4c)
    if numLen > 4:
        print('数字最多是4位')
        return

    elif numLen < 4:
        # print('数字不足4位前面补零')
        num4c = '0'*(4-numLen) + num4c
        # print(num4c)

    retStr = ''
    # 千位
    if num4c[0] != '0':
        retStr += getNum(num4c[0]) + '仟'

    # 百位
    if num4c[1] != '0':
        retStr += getNum(num4c[1]) + '佰'
    else:
        retStr += '零'

    # 十位
    if num4c[2] != '0':
        retStr += getNum(num4c[2]) + '拾'
    else:
        retStr += '零'

    # 个位
    if num4c[3] != '0':
        retStr += getNum(num4c[3])

    # 去掉连续的零
    retStr = retStr.replace('零零零','零').replace('零零','零')

    # 去掉开头的零
    if  retStr.startswith('零'):
        retStr = retStr[1:]

    # 去掉结尾的零
    if retStr.endswith('零'):
        retStr = retStr[:-1]

    print('对应的大写金额是:' + retStr)
    return retStr

convert4digits(inNum)
jcyrss commented 4 years ago

下载压缩包 http://cdn1.python3.vip/files/py/prac_dict3.zip

解压该压缩包,里面 包含了3个文件。 都是数据库中导出的数据文件,记录了白月黑羽的老师和授课信息。

其中

  1. teacher.txt 文件中包含了 老师信息,格式如下:
id;user_id;desc;display_idx;realname
42;106;;1;白月黑羽
43;107;;2;紫气一元
44;108;;3;黑羽拜月

首行表示 下面数据各字段的含义。 
第1列id 表示老师的id号。
第2、3、4 列的含义大家可以先不必了解。 
第5列realname 表示 老师的姓名
  1. course.txt 文件中包含了 课程信息,格式如下:
id;name;desc;display_idx
32;软件测试框架课程;;1
33;web测试技术课程;;2

首行表示 下面数据各字段的含义。 
第1列id 表示课程的id号
第2列name 表示 课程的名称
第3、4 列的含义大家可以先不必了解。 
  1. teacher_course.txt 文件中包含了 老师授课信息,格式如下:
teacher_id;course_id
42;32
42;33

首行表示 下面数据各字段的含义
第1列teacher_id 表示老师的id号(对应第一张表的老师id号)
第2列course_id表示 课程的id号(对应第二张表的课程id号)。

要求大家编写一个python程序,根据这3张表的内容,输出一个包含老师授课信息的文件。 要求格式为 老师姓名: 课程名,例如

白月黑羽       : 软件测试框架课程
白月黑羽       : web测试技术课程
紫气一元       : 软件测试框架课程
紫气一元       : web测试技术课程
紫气一元       : app测试技术课程
jcyrss commented 4 years ago

md5

filecheckmd5.zip

jcyrss commented 4 years ago

httpclient1.zip

jcyrss commented 4 years ago

httpclient2.zip

jcyrss commented 4 years ago

学生名单.zip

jcyrss commented 3 years ago
from random import  randint
import time

# 鹰妖
# 属性:类型名 typename

class Eagle:
    typeName = '鹰妖'

# 狼妖
# 属性:类型名 typename
class Wolf:
    typeName = '狼妖'

# 父类:战士 
class Warrior:

    def __init__(self,name):
        self.strength = self.maxStrength
        self.name = name

    def heal(self,stoneCount,player):
        if player.stoneNumber < stoneCount:
            print('剩余灵石不足')
            return

        self.strength += stoneCount
        if self.strength > self.maxStrength:
            self.strength = self.maxStrength

        player.stoneNumber -= stoneCount

    def fightWithMonster(self,monster):
        if monster.typeName in self.fightRule:
            self.strength -= self.fightRule[monster.typeName]
        else:
            print('不支持的妖怪类型')

# 弓箭兵
# 属性:类型名 typename
#       雇佣价: 100灵石
#       最大生命值: 100
#       生命值
#        名字
#      和妖怪战斗 fightWithMonster
class Archer(Warrior):
    typeName = '弓箭兵'
    price         = 100
    maxStrength   = 100
    fightRule     = {
        '鹰妖' : 20,
        '狼妖' : 80,
    }

# 斧头兵
# 属性:类型名 typename
#     雇佣价: 120 灵石
#     最大生命值: 120
#       生命值
#        名字
#      和妖怪战斗 fightWithMonster

class Axeman(Warrior):
    typeName = '斧头兵'
    price         = 120
    maxStrength   = 120
    fightRule     = {
        '鹰妖' : 80,
        '狼妖' : 20,
    }

# 玩家
# 属性: 灵石数量

class Player:
    def __init__(self,stoneNumber):
        self.stoneNumber = stoneNumber
        self.warriors = {}

    def hireOne(self, WarriorType):
        if self.stoneNumber < WarriorType.price:
            print(f'灵石不足,您只有 {player.stoneNumber} 灵石')
            return

        while True:
            name = input('请给雇佣战士起一个名字')
            name = name.strip()
            if len(name) == 0:
                print('名字无效')
                continue
            if name in self.warriors:
                print('这个名字已经被用了')
            else:
                break

        self.warriors[name] = WarriorType(name)

        self.stoneNumber -= WarriorType.price

    # 雇佣战士
    def hireWarriors(self):
        menu = '''
        请选择雇佣操作
        1 - 雇佣弓箭兵
        2 - 雇佣斧头兵
        3 - 退出 
        : '''

        while True:
            choice = input(menu)
            if choice not in ['1','2','3']:
                print('输入错误')
                continue

            if choice == '3':
                break

            # 雇佣弓箭兵
            if choice == '1':
                self.hireOne(Archer)
            # 雇佣斧头兵
            else:
                self.hireOne(Axeman)

        self.printInfo()

    def printInfo(self):
        print('\n您麾下战士情况如下')
        for name,warrior in self.warriors.items():
            print(f'{name}: {warrior.typeName} 生命值 {warrior.strength}')

        print(f'您的灵石还剩余{self.stoneNumber}')

# 森林
# 属性: 妖怪
class Forest:
    def __init__(self,monster):
        self.monster = monster

# 森林 列表
forestList = []
for i in range(7):
    if randint(0,1) == 0:
        monster = Eagle()
    else:
        monster = Wolf()

    forestList.append(Forest(monster))

print('\n前方森林里的妖怪是:')
for f in forestList:
    print(f.monster.typeName)

time.sleep(10)

print('\n'*20)

#创建玩家
player = Player(1000)

player.hireWarriors()

print('\n\n ****** 出发啦 *******')

for no,forest in enumerate(forestList):
    # 战斗
    while True:
        print(f'\n\n ### 现在到了第 {no+1} 座森林 ### ')

        while True:
            warriorName  = input('您要派出的战士是?')
            if warriorName not in player.warriors:
                print('没有这个战士')
                continue
            break

        warrior = player.warriors[warriorName]

        print(f'当前森林里面是 {forest.monster.typeName}')

        warrior.fightWithMonster(forest.monster)

        print(f'经过战斗,你的战士{warriorName},生命值还有{warrior.strength}')

        if warrior.strength <= 0:
            print('他,光荣牺牲了')
            player.warriors.pop(warriorName)
            continue
        else:
            break

    # 疗伤处理
    while True:
        player.printInfo()

        op = input('''\n请输入疗伤战士名字和灵石数量,格式如为:姓名+20
        直接回车退出疗伤:''')

        if op == '':
            break

        name,stoneCount = op.split('+')
        stoneCount = int(stoneCount)

        player.warriors[name].heal(stoneCount,player)

player.printInfo()
jcyrss commented 3 years ago
from selenium import webdriver
wd = webdriver.Chrome()
wd.implicitly_wait(5)
wd.get('https://y.qq.com/n/yqq/toplist/27.html#stat=y_new.toplist.menu.27')

elements = (wd.find_element_by_class_name('songlist__list')).find_elements_by_tag_name('li')#所有歌曲
for element in elements:
    rank = (element.find_element_by_class_name('songlist__rank')).find_element_by_tag_name('i')
    if rank.get_attribute('class') == 'icon_rank_up':
        song = element.find_element_by_class_name('js_song')#上升 歌曲名
        name = (element.find_element_by_class_name('songlist__artist')).get_attribute('title')#上升 歌手名
        print(f'{song.text:20}: {name}')