打印“查询"时获取 PY_VAR1 [英] Getting PY_VAR1 when i print 'query'

查看:24
本文介绍了打印“查询"时获取 PY_VAR1的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在制作一个简单的网页抓取代码,当我尝试打印一个值时,它给了我其他东西.

Im making a simple web srape code and when i try to print a value it gives me something else.

def PeopleSearch():
query = SearchTerm
query = ('what is '+ query)
print str(query)


SearchTerm = StringVar(None)
SearchText = Entry(app, textvariable=SearchTerm)
SearchText.pack()

'SearchTerm' 来自文本框.如果我尝试打印 str(query)我得到 PY_VAR1.无论我输入什么,我都会得到 PY_VAR1.

'SearchTerm' is gotten from a text Box. If i try to print str(query) i get PY_VAR1. And i get PY_VAR1 no matter what i type.

但这只有在我从包含 tkinter 模块的程序中执行时才会发生.没有 GUI,它会准确打印我输入的内容.

But this only happens when i do it from program containing tkinter module. Without GUI, it prints exactly what i typed in.

怎么了?嗯?

推荐答案

StringVar 是一个管理值的对象 - 获取你想要的值本身 SearchTerm.get()

StringVar is an object which manages the value - to get the value itself you want SearchTerm.get()

这篇关于打印“查询"时获取 PY_VAR1的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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