Ⅰ message.py 是做什么的 我看到有python脚本调用这个模块, 怎么安装这个模块

从文件名字来看应是设置或获取相关信息的模块,如果这个模块只是单独的一个文件的话那就把它复制到你当前项目中直接用

Ⅱ python line 1 def say(message,times=1) SyntaxError: invalid syntax

# if you use python2.x, and you save your code in a file, it will work!
# I think you use python3.x, so you should change
# print 'Hello World!' to
# print('Hello World!') because print is a function in python3.x.

Ⅲ python tkinter的messagebox能否调整大小或添加滚动条如何调

你好,tkinter的messagebox是不可以调整大小的。如果你需要的话,你可以换其他的来实现,下面是一个例子。
from tkinter import * #If you get an error here, try Tkinter not tkinter

def Dialog1Display():
Dialog1 = Toplevel(height=100, width=100) #Here

def Dialog2Display():
Dialog2 = Toplevel(height=1000, width=1000) #Here

master=Tk()

Button1 = Button(master, text="Small", command=Dialog1Display)
Button2 = Button(master, text="Big", command=Dialog2Display)

Button1.pack()
Button2.pack()
master.mainloop()

Ⅳ python 弹出式对话框

不知道你用的什么版本,我修改了一下,测试通过(python2.7):

#coding=utf-8
importTkinter
importtkMessageBox

defshow():
tkMessageBox.showinfo(title='aaa',message='bbb')

defcreatfram():
root=Tkinter.Tk()
b=Tkinter.Button(root,text="关于",command=show)
b.pack()
root.mainloop()

creatfram()
如果解决了您的问题请点赞!

如果未解决请继续追问

Ⅳ 求教,如何使用Python向activeMQ发送ByteMessage类型的消息

你好,具体代码可以参考下面的:
import javax.jms.Connection;
import javax.jms.DeliveryMode;
import javax.jms.Destination;
import javax.jms.JMSException;
import javax.jms.MessageProcer;
import javax.jms.ObjectMessage;
import javax.jms.Session;
import javax.jms.TextMessage;

import org.apache.activemq.ActiveMQConnectionFactory;
import org.apache.activemq.ActiveMQPrefetchPolicy;
import org.apache.camel.component.jms.JmsMessage;
import org.apache.xbean.spring.context.;

//发送TextMessage
public class SendMessage {

private static final String url = "tcp://localhost:61616";;
private static final String QUEUE_NAME = "choice.queue";
protected String expectedBody = "<hello>world!</hello>";

public void sendMessage() throws JMSException{

Connection connection = null;

try{
ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory(url);
connection = connectionFactory.createConnection();

connection.start();
Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
Destination destination = session.createQueue(QUEUE_NAME);
MessageProcer procer = session.createProcer(destination);
TextMessage message = session.createTextMessage(expectedBody);
message.setStringProperty("headname", "remoteB");
procer.send(message);
}catch(Exception e){
e.printStackTrace();
}finally{
connection.close();
}
}

***************************************************************************************
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;

import javax.jms.BytesMessage;
import javax.jms.Connection;
import javax.jms.DeliveryMode;
import javax.jms.Destination;
import javax.jms.JMSException;
import javax.jms.MessageProcer;
import javax.jms.Session;

import org.apache.activemq.ActiveMQConnectionFactory;
//发送BytesMessage
public class SendMessage {

private String url = "tcp://localhost:61616";

public void sendMessage() throws JMSException{
ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory(url);
Connection connection = connectionFactory.createConnection();
connection.start();
Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
Destination destination = session.createQueue("test.queue");
MessageProcer procer = session.createProcer(destination);
procer.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
BytesMessage message = session.createBytesMessage();
byte[] content = getFileByte("d://test.jar");
message.writeBytes(content);
try{
procer.send(message);
System.out.println("successful send message");
}catch(Exception e){
e.printStackTrace();
e.getMessage();
}finally{
session.close();
connection.close();
}
}

private byte[] getFileByte(String filename){
byte[] buffer = null;
FileInputStream fin = null;
try {
File file = new File(filename);
fin = new FileInputStream(file);
buffer = new byte[fin.available()];
fin.read(buffer);
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
fin.close();
} catch (IOException e) {
e.printStackTrace();
}
}
return buffer;
}
发送完消息后可以访问
http://localhost:8161/admin/queues.jsp
看到相应的queue中是否有消息

适用收取TextMessage消息
import javax.jms.Connection;
import javax.jms.Destination;
import javax.jms.JMSException;
import javax.jms.Message;
import javax.jms.MessageConsumer;
import javax.jms.Session;
import javax.jms.TextMessage;

import org.apache.activemq.ActiveMQConnectionFactory;

public class ReceiveMessage {

private static final String url = "tcp://172.16.168.167:61616";
private static final String QUEUE_NAME = "szf.queue";

public void receiveMessage(){
Connection connection = null;
try{
try{
ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory(url);
connection = connectionFactory.createConnection();
}catch(Exception e){
// ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory(url);
// connection = connectionFactory.createConnection();
}
connection.start();
Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
Destination destination = session.createQueue(QUEUE_NAME);
MessageConsumer consumer = session.createConsumer(destination);
consumeMessagesAndClose(connection,session,consumer);
}catch(Exception e){

}
}

protected void consumeMessagesAndClose(Connection connection,
Session session, MessageConsumer consumer) throws JMSException {
for (int i = 0; i < 1;) {
Message message = consumer.receive(1000);
if (message != null) {
i++;
onMessage(message);
}
}
System.out.println("Closing connection");
consumer.close();
session.close();
connection.close();
}

public void onMessage(Message message){
try{
if (message instanceof TextMessage) {
TextMessage txtMsg = (TextMessage)message;
String msg = txtMsg.getText();
System.out.println("Received: " + msg);
}
}catch(Exception e){
e.printStackTrace();
}
}

public static void main(String args[]){
ReceiveMessage rm = new ReceiveMessage();
rm.receiveMessage();
}
}

Ⅵ 这段python代码和报错是什么意思

是指代码中_string这个对象没有定义。没定义没声明当然就无法调用。

Ⅶ Python中用wx.MessageDialog生成对话框,wx.ICON_QUESTION不能显示问号图标。

import wx

class MyFrame(wx.Frame):

def __init__(self, parent, id):
wx.Frame.__init__(self, parent, id, u'测试面板Panel', size = (600, 300))

#创建面板
panel = wx.Panel(self)

#在Panel上添加Button
button = wx.Button(panel, label = u'关闭', pos = (150, 60), size = (100, 60))

#绑定单击事件
self.Bind(wx.EVT_BUTTON, self.OnCloseMe, button)

def OnCloseMe(self, event):
dlg = wx.MessageDialog(None, u"消息对话框测试", u"标题信息", wx.YES_NO | wx.ICON_QUESTION)
if dlg.ShowModal() == wx.ID_YES:
self.Close(True)
dlg.Destroy()

if __name__ == '__main__':
app = wx.PySimpleApp()
frame = MyFrame(parent = None, id = -1)
frame.Show()
app.MainLoop()

Ⅷ python 3.4 中原来的tkMessageBox变成啥了

1、在python3.4中,原来的tkMessageBox变成tkinter.messagebox,效果如下图。



(8)pythonmessage扩展阅读

python的应用

1、系统编程:提供API(Application Programming Interface应用程序编程接口),是很多系统管理员理想的编程工具。

2、图形处理:有PIL、Tkinter等图形库支持,能方便进行图形处理。

3、数学处理:NumPy扩展提供大量与许多标准数学库的接口。

4、文本处理:python提供的re模块能支持正则表达式,还提供SGML,XML分析模块,许多程序员利用python进行XML程序的开发

5、数据库编程:程序员可通过遵循Python DB-API(数据库应用程序编程接口)规范的模块与Microsoft SQL Server,Oracle,Sybase,DB2,MySQL、SQLite等数据库通信。

6、python自带有一个Gadfly模块,提供了一个完整的SQL环境。

7、网络编程:提供丰富的模块支持sockets编程,能方便快速地开发分布式应用程序。

8、Web编程:应用的开发语言,支持最新的XML技术。

9、多媒体应用:Python的PyOpenGL模块封装了“OpenGL应用程序编程接口”,能进行二维和三维图像处理。

10、pymo引擎:PYMO全称为python memories off,是一款运行于Symbian S60V3,Symbian3,S60V5, Symbian3, Android系统上的AVG游戏。

Ⅸ Python 里msg是什么意思

HTTPError: HTTP Error 407: Proxy Authentication Required ( The ISA Server requires authorization to fulfill the request. Access to the Web Proxy filter is denied. )

Ⅹ python用sendmessage函数向其他程序的编辑框(当前激活窗口,并且在活动光标处)内发送

这就是个windows SDk的编抄程问题

#coding:utf-8

fromctypesimport*

WM_SETTEXT = 0x000C


defChangeActiveWindowTtile():
hwnd=windll.user32.FindWindowW(u"Notepad",u"无标题-记事本")
if(windll.user32.IsWindow(hwnd)):
windll.user32.SendMessageW(hwnd,WM_SETTEXT,None,u"我是标题")

ChangeActiveWindowTtile()