小编cha*_*ran的帖子

Python Tkinter抛出Tcl错误

我正在学习Python中的基本GUI,我遇到了一个示例,用于从Stack Overflow上的文件资源管理器中读取文件名.

from Tkinter import Tk
from tkFileDialog import askopenfilename
Tk().withdraw() # we don't want a full GUI, so keep the root window from appearing
filename = askopenfilename() # show an "Open" dialog box and return the path to the selected file
print(filename)
Run Code Online (Sandbox Code Playgroud)

当我尝试在IDLE中运行它时,这个特殊的脚本工作正常,但是如果我在Windows 7中从命令提示符处尝试,则不会运行.

Python版本:2.7.这是我得到的输出错误.

>>> from Tkinter import Tk
>>> from tkFileDialog import askopenfilename
>>> Tk().withdraw()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Python27\Lib\lib-tk\Tkinter.py", line 1685, in __init__
self.tk = _tkinter.create(screenName, …
Run Code Online (Sandbox Code Playgroud)

tk-toolkit tkinter python-2.7

10
推荐指数
3
解决办法
2万
查看次数

从shell脚本中的属性文件中读取数据

我正在编写一个shell脚本,它从属性文件中读取数据并将其存储到shell脚本中的本地变量中.问题是当我试图从文件中读取多个属性并形成一个字符串时,它已经过了写

#!/bin/bash
. /opt/oracle/scripts/user.properties

echo $username
echo $password
echo $service_name

conn=$username$password$service_name
echo $conn
Run Code Online (Sandbox Code Playgroud)

username = xxxx password = yyyy和service_name = zzzz的值我希望输出为

xxxxyyyyzzzz 
Run Code Online (Sandbox Code Playgroud)

但而不是我得到的输出

zzzz
Run Code Online (Sandbox Code Playgroud)

请告诉我我在哪里做错了?

linux shell properties-file

4
推荐指数
1
解决办法
3万
查看次数

标签 统计

linux ×1

properties-file ×1

python-2.7 ×1

shell ×1

tk-toolkit ×1

tkinter ×1