我做了一个非常简单的程序,我试图将它导出到一个app文件.我目前正在使用Python 3.6和py2app将py文件转换为app.所以我创建了安装文件:
from setuptools import setup
OPTIONS = {'iconfile':'sc.icns',}
setup(
app = ['hello.py'],
options = {
'py2app': OPTIONS},
setup_requires = ['py2app']
)
Run Code Online (Sandbox Code Playgroud)
然后在终端我输入:
python3 hello_setup.py py2app
Run Code Online (Sandbox Code Playgroud)
几秒后它创建了dist文件夹,其中有hello.app,问题是当我运行它时,它出现一个窗口,显示" hello error "然后我打开应用程序内的.exec文件以查看终端它显示了这个错误:
ValueError:字符U + 6573552f不在[U + 0000; U + 10FFFF]
为什么会出现?我如何解决它?非常感谢你.
如果需要,这里是'hello.py'的代码
from tkinter import *
from tkinter import messagebox
root = Tk()
def printworld():
messagebox.showinfo('Hello', 'Hello World')
button1 = Button(root, text='Press me!', command=printworld)
button1.pack()
root.mainloop()
Run Code Online (Sandbox Code Playgroud) 我正在为一个学校项目制作一个程序.这是模拟联合国.
countries = ['Australia', 'Brazil', 'Canada']
class delegate(object):
def __init__(self, country):
self.country = country
Run Code Online (Sandbox Code Playgroud)
我有一个国家列表和一个名为delegate的类.因此,每个委托对象必须有一个国家/地区.通常我会这样做:
mexico = delegate('Mexico')
Run Code Online (Sandbox Code Playgroud)
就是这样.但我想循环遍历国家/地区列表并为每个列表创建类实例.我的意思是:
australia = delegate('Australia')
brazil = delegate('Brazil')
canada = delegate('Canada')
Run Code Online (Sandbox Code Playgroud)
等等. 我该怎么做? 非常感谢你!!