pythonmessage
Ⅰ 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()