python - 蟒蛇 | tkinter:tkinter.END 做什么?
问题描述
通过一本书学习python,tkinter.END用在一块代码中,不做解释
import tkinter
def count(text, out_data):
""" Update out_data with the total number of As, Ts, Cs, and Gs found in text."""
data = text.get('0.0', **tkinter.END**)
counts = {}
for char in 'ATCG':
counts[char] = data.count(char)
out_data.set('Num As: {0} Num Ts: {1} Num Cs: {2} Num Gs: {3}'.format(
counts['A'], counts['T'], counts['C'], counts['G']))
...
我在网上看过,我只遇到过它的例子,从来没有提到它的功能。help(tkinter)
我在 shell 中尝试过,END = 'end'
但它不是很有用。如果需要更多代码,请告诉我。不想发布整个代码,让您无缘无故地阅读更多内容。
解决方案
它不“做”任何事情。它是一个常量,即字符串“end”。在这种情况下,它表示紧接在用户输入的最后一个字符之后的点。文本小部件上的函数get
需要两个值:开始位置和结束位置。
注意:在 , 行text.get('0.0', tkinter.END)
中'0.0'
是无效的(尽管,tkinter 欣然接受它,并将其视为'1.0'
)。文本索引的格式为line.character。行从 1 开始计数,字符从 0 开始。所以,第一个字符是'1.0'
,不是'0.0'
。
推荐阅读
- drupal - Drupal 8 - 如何将内容类型值限制为实体引用
- pandas - 每列熊猫的饼图
- javascript - 通过变量名调用 jquery 插件
- ruby-on-rails - Ruby on Rails:尝试基于一组值发出多个 API 请求。如何将这些值作为参数插入 API URL?
- python - 如何向量化词标记字典(词袋实现)
- python - 我在检查过的标签和类之后进行了网络抓取,它返回无
- c# - 不断检查进程是否打开
- assembly - 32 位程序集引导加载程序在 VM/qemu 中有效,但在真实 PC 上无效
- oracle - 如何获取在 rds 上运行的 oracle 数据库的主机名
- python - LOG 问题 sklearn 错误 ValueError:输入包含 NaN、无穷大或对于 dtype('float64') 而言太大的值