错误?无法弄清楚 [英] Error? Can’t Figure Out

查看:75
本文介绍了错误?无法弄清楚的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在创建一个tkinter程序,并遇到了这个奇怪的错误。这是我的代码:

I am creating a tkinter program and ran into this weird error. Here is my code:

from Tkinter import *   
def get_info(key):     
    pass   
def create_new():  
    create = Toplevel(root)
    create.title('Create A New Contact')
    Label(create, text='Name: ').grid(row=0, sticky=W+E)
    name = Entry(create, width=8).grid(row=1, sticky=W+E)
    Label(create, text='Address(ex. 1111 Main St, MyCity, Anystate 12345): ', wrapLength=1).grid(row=2, sticky=W+E)
    address = Entry(create, width=8).grid(row=3, sticky=W+E)
def access():
    access_window = Toplevel(root)
    access_window.title("Access a Contact")
    Label(access_window, text="Enter a first name: ‘).grid(row=0, sticky=‘W+E’)#Error here
    access_key = Entry(access_window, width=8).grid(row=0, sticky='W+E')
    Button(access_window, text="Submit", command=lambda: get_info(access_key.get('0.0', 'end-1c'))).grid(row=2, sticky='W+E')
root = Tk()
root.title('Address Book')
button1 = Button(root, text="Create New", command=create_new).grid(row=0, column=0)
button2 = Button(root, text="Access Person", command=access).grid(row=0, column=1)

控制台显示:

Error: EOL while scanning string literal.

我该如何解决?

推荐答案

您需要使用相同的引号来标记字符串的开头和结尾。

You need to use the same kind of quotation marks to mark the start and end of a string.

因此,突出显示的行需要使用一致的引号-不应混用单引号和双引号。您的行需要看起来像这样

So the line you highlighted needs use consistent quotation marks - you shouldn't mix single and double quotes. Your line need to look like this

Label(access_window, text="Enter a first name: ").grid(row=0, sticky=‘W+E’)

或者这

Label(access_window, text='Enter a first name: ').grid(row=0, sticky=‘W+E’)

不是这样,在这里您以双引号开始并以单引号结束

Not this, where you start with a double quote and end with a single quote

Label(access_window, text="Enter a first name: ‘).grid(row=0, sticky=‘W+E’)

这篇关于错误?无法弄清楚的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆