RError.com

RError.com Logo RError.com Logo

RError.com Navigation

  • 主页

Mobile menu

Close
  • 主页
  • 系统&网络
    • 热门问题
    • 最新问题
    • 标签
  • Ubuntu
    • 热门问题
    • 最新问题
    • 标签
  • 帮助
主页 / user-280178

андрей гривкин's questions

Martin Hope
андрей гривкин
Asked: 2020-01-09 01:35:14 +0000 UTC

针对 tkinter Python3 检查用户在 Entry 中输入的字符串

  • -1

用户在 Entry 中输入一个字符串,然后使用 get() 获取输入的字符串并检查它是否等于预定义的字符串。但问题是,即使来自 Entry 的行与所需行完全相似,程序也不会进入条件体。我完全不明白为什么。请帮忙。

most = Entry(root, bg='white', width=80, bd=0, fg='#01213d', font=('Arial', 8, 'bold'))
most.place(x=63, y=89)
if most.get().lower() == 'bridge':
    e_cl = e_cl + 1
python-3.x
  • 1 个回答
  • 10 Views
Martin Hope
андрей гривкин
Asked: 2020-01-08 05:24:39 +0000 UTC

图片未显示在标签中

  • 3

在此处输入图像描述我正在开发我的第一个窗口应用程序,现在我遇到了一个问题。我调用一个带参数的函数,根据参数,标签中应该显示不同的图像。但相反,它只是一个灰屏,按钮上也没有图像,但按钮正常执行其功能。在一切正常之前,我不知道该怎么做。提前致谢

from tkinter import *


def eclick(event):
   root.destroy()

def edscr():

    e_sc_1 = PhotoImage(file='e_scr_1.png')
    e_scr_1 = Label(root, image=e_sc_1)
    e_scr_1.place(x=0, y=0)

    e_but = PhotoImage(file='but_e.png')
    but_e = Button(root, width=477, height=16, image=e_but)
    but_e.place(x=130, y=350)
    but_e.bind('<Button-1>', eclick)


root = Tk()
edscr()

root.mainloop()
python python-3.x
  • 1 个回答
  • 10 Views
Martin Hope
андрей гривкин
Asked: 2020-01-07 22:29:55 +0000 UTC

在 Python 中使用全局

  • 9

你好,我熟悉python,在c++之后我断然不明白使用全局变量的原理。如果一个位于def中的变量指定了全局,那么它的值是否可以在这个函数之外使用,我肯定不能。也许只是因为我是一个初学者,而显而易见的事情对我来说仍然太复杂了。

def check():
    global urokb_in
    urokb_in = 1
    with open('users.txt', 'r') as f:
        line = f.readline()
        f.close()
    with open('progress.txt', 'r') as k:
        while True:
            global uroka_in
            lines = k.readline()
            if line == lines.rstrip():
                uroka_in = int(k.readline().rstrip())
                urokb_in = uroka_in + 1
                uroka_str = str(uroka_in)
                urokb_str = str(urokb_in)
                lines.replace(uroka_str, urokb_str)
                k.close()
                break
            if not lines:
                k.close()
                urokb_in = 1
                with open('progress.txt', 'a') as j:
                    j.write(line)
                    j.write('\n')
                    j.write(str(urokb_in))
                    j.write('\n')
                    j.close()
                    break
    if urokb_in == 1:
       educate__scr = PhotoImage(file='e_scr_1.png')
       educate_label = Label(root, image=educate__scr)
       educate_label.place(x=0, y=0)

更有经验的编码人员告诉我如何解决它。SyntaxError: name 'urokb_in' 在全局声明之前使用

python python-faq
  • 4 个回答
  • 10 Views
Martin Hope
андрей гривкин
Asked: 2020-01-07 17:52:40 +0000 UTC

从文件中获取字符串并将其转换为 int Python 类型

  • 0

该函数从 users.txt 文件中读取用户的登录名(那里总是只有一个登录名),然后查找相同的 inprogress.txt,如果找到,则需要将登录名后面的行替换为再一个,从 1 到 2,从 2 等。.d。是班级编号。如果是第一次输入登录名,那么只需将其写入progress后跟1。问题是我不明白如何从文件中获取带有数字的这一行,将其转换为int,加1,然后把它写到同一个地方。或许答案是显而易见的,但我对 Python 才熟悉几天,还是不太了解。提前致谢

with open('users.txt', 'r') as f:
line = f.readline()
f.close()
with open('progress.txt', 'r') as k:
while True:
    global uroka_in
    lines = k.readline()
    if line == lines.rstrip():
        uroka_in = int(k.readline().rstrip())
        urokb_in = uroka_in + 1
        uroka_str = str(uroka_in)
        urokb_str = str(urokb_in)
        lines.replace(uroka_str, urokb_str)
        k.close()
        break
    if not lines:
        k.close()
        global urokb_in
        urokb_in = 1
        with open('progress.txt', 'a') as j:
            j.write(line)
            j.write('\n')
            j.write(str(urokb_in))
            j.write('\n')
            j.close()
            break

示例 progress.txt 文件:

username1
1
username2
1
username3
1

编辑:

def user():
with open('users.txt') as k:
    user = k.readline()
    k.close()
def increment_counter(user, 'progress.txt'):
    with open('progress.txt', 'r') as f:
     data = yaml.safe_load(f.read())
    data[user] += 1
    with open('progress.txt', 'w') as f:
    yaml.dump(data, f, indent=2, default_flow_style=False)
python
  • 2 个回答
  • 10 Views
Martin Hope
андрей гривкин
Asked: 2020-01-07 04:41:00 +0000 UTC

我在哪里可以获得俄英词典的词库?

  • 3

我正在用 Python 3 编写一个简单的英俄词典。用户输入一个单词 - 用英语显示它的类似物(如何)。因此,查看一个单词的翻译是通过一个 .txt 文件执行的,该文件中写入了单词(示例):

дом
house
дом
цветок
flower
цветок

等等。

对于一本至少有能力的字典,你需要 2000 多个单词。也许已经有一个使用某些站点的资源以这种方式填充文件的脚本?

我是初学者,刚开始理解OOP,所以不能自己写这个脚本,手动输入6000字太费时间了。

python
  • 2 个回答
  • 10 Views

Sidebar

Stats

  • 问题 10021
  • Answers 30001
  • 最佳答案 8000
  • 用户 6900
  • 常问
  • 回答
  • Marko Smith

    我看不懂措辞

    • 1 个回答
  • Marko Smith

    请求的模块“del”不提供名为“default”的导出

    • 3 个回答
  • Marko Smith

    "!+tab" 在 HTML 的 vs 代码中不起作用

    • 5 个回答
  • Marko Smith

    我正在尝试解决“猜词”的问题。Python

    • 2 个回答
  • Marko Smith

    可以使用哪些命令将当前指针移动到指定的提交而不更改工作目录中的文件?

    • 1 个回答
  • Marko Smith

    Python解析野莓

    • 1 个回答
  • Marko Smith

    问题:“警告:检查最新版本的 pip 时出错。”

    • 2 个回答
  • Marko Smith

    帮助编写一个用值填充变量的循环。解决这个问题

    • 2 个回答
  • Marko Smith

    尽管依赖数组为空,但在渲染上调用了 2 次 useEffect

    • 2 个回答
  • Marko Smith

    数据不通过 Telegram.WebApp.sendData 发送

    • 1 个回答
  • Martin Hope
    Alexandr_TT 2020年新年大赛! 2020-12-20 18:20:21 +0000 UTC
  • Martin Hope
    Alexandr_TT 圣诞树动画 2020-12-23 00:38:08 +0000 UTC
  • Martin Hope
    Air 究竟是什么标识了网站访问者? 2020-11-03 15:49:20 +0000 UTC
  • Martin Hope
    Qwertiy 号码显示 9223372036854775807 2020-07-11 18:16:49 +0000 UTC
  • Martin Hope
    user216109 如何为黑客设下陷阱,或充分击退攻击? 2020-05-10 02:22:52 +0000 UTC
  • Martin Hope
    Qwertiy 并变成3个无穷大 2020-11-06 07:15:57 +0000 UTC
  • Martin Hope
    koks_rs 什么是样板代码? 2020-10-27 15:43:19 +0000 UTC
  • Martin Hope
    Sirop4ik 向 git 提交发布的正确方法是什么? 2020-10-05 00:02:00 +0000 UTC
  • Martin Hope
    faoxis 为什么在这么多示例中函数都称为 foo? 2020-08-15 04:42:49 +0000 UTC
  • Martin Hope
    Pavel Mayorov 如何从事件或回调函数中返回值?或者至少等他们完成。 2020-08-11 16:49:28 +0000 UTC

热门标签

javascript python java php c# c++ html android jquery mysql

Explore

  • 主页
  • 问题
    • 热门问题
    • 最新问题
  • 标签
  • 帮助

Footer

RError.com

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

帮助

© 2023 RError.com All Rights Reserve   沪ICP备12040472号-5