|
|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
做习题时发现,textbox的text部分,既可以是读出来的字符串,也可以是文本本身。
import easygui as g
file_path = g.fileopenbox(default='*.txt')
with open(file_path) as f:
## f = f.read() #此句不输出,照样可以正常显示,请问是否可以省略,使得执行更高效一些呢?
g.textbox(text=f)
按照逻辑,一般打开文档,需要将文档内容读出来,然后再输出,但是textbox本身貌似已经做了处理。
查了一下help命令,没有明确提出,鉴于还是新手,不知道怎么查找textbox里面的源代码是否已经做了相应的处理,使得文件本身也可以直接放进去。
谁能指点一下呢?谢谢。
----------------------------------------------------------------------------------------------
Help on function textbox in module easygui:
textbox(msg='', title=' ', text='', codebox=0)
Display some text in a proportional font with line wrapping at word breaks.
This function is suitable for displaying general written text.
The text parameter should be a string, or a list or tuple of lines to be
displayed in the textbox.
:param str msg: the msg to be displayed
:param str title: the window title
:param str text: what to display in the textbox
:param str codebox: if 1, act as a codebox
----------------------------------------------------------------------------------------------
跟textbox无关,因为打开文件f不进行read操作那么f可以被当做是read后的结果
|
|