Python网络响应'b'(Python Networking responding wtih 'b')
我刚刚开始使用python网络,在看了几个网络教程之后,我给了它一个去...唯一的问题是,每当我从服务器得到响应时,它打印如下:
收到:(主持人和港口)b'Hey' - 我没有把b放在任何地方。
这是服务器代码:
import socket import tkinter import time import sys def Main(): top = tkinter.Tk() top.configure(background='black') host = '10.0.0.2' port = 5000 s = socket.socket() s.bind((host, port)) s.listen(1) c, addr = s.accept() while True: con = tkinter.Label(top, text="Connection from: " + str(addr), bg='red', fg='white').pack() data = c.recv(1024) if not data: break conn = tkinter.Label(top, text="Recieved from: " + str(addr) + str(data), bg='black', fg='white').pack() top.mainloop() c.close() Main()
我的客户:
import socket def Main(): host = '10.0.0.2' port = 5000 s = socket.socket() s.connect((host, port)) message = input("> ") while message != 'quit': s.send(message.encode('ascii')) message = input(">") s.close() Main()
感谢您的任何意见 - 我还不是很擅长这个! (我的主机不是我的电脑,所以这不是问题)
I've just started python networking, and after looking at a few internet tutorials, I gave it a go... only problem is, whenever I get a response from the sever, it prints as in:
Recieved from: (Host & Port)b'Hey' - where I haven't put the b anywhere.
Here is the server code:
import socket import tkinter import time import sys def Main(): top = tkinter.Tk() top.configure(background='black') host = '10.0.0.2' port = 5000 s = socket.socket() s.bind((host, port)) s.listen(1) c, addr = s.accept() while True: con = tkinter.Label(top, text="Connection from: " + str(addr), bg='red', fg='white').pack() data = c.recv(1024) if not data: break conn = tkinter.Label(top, text="Recieved from: " + str(addr) + str(data), bg='black', fg='white').pack() top.mainloop() c.close() Main()
And my client:
import socket def Main(): host = '10.0.0.2' port = 5000 s = socket.socket() s.connect((host, port)) message = input("> ") while message != 'quit': s.send(message.encode('ascii')) message = input(">") s.close() Main()
Thanks for any input - I'm not really good at this yet! (My hosts aren't my computer so that's not the issue)
原文:https://stackoverflow.com/questions/29179994
满意答案
从您的本地项目文件夹中的终端...(并且您已经为您的叉子配置了远程 )
git fetch upstream git checkout master git merge upstream/master
(请参阅github 同步fork文档以获取更多信息)
From your terminal in your local project folder...(and provided you have configured the remote for your fork)
git fetch upstream git checkout master git merge upstream/master
(See the github Syncing a fork docs for more info)
相关问答
更多更新我的github回购,从另一个项目[复制](Update my github repo which is forked out from another project [duplicate])
如何更新GitHub分支库?(How do I update a GitHub forked repository?)
如何通过Github API从它的原始更新fork(How to update a fork from it's original via the Github API)
如何在GitHub上的别人的分支上获取分支?(How do I fetch a branch on someone else's fork on GitHub? [duplicate])
叉和分支在github上的区别(difference between fork and branch on github)
Github:分成新的分支(Github: fork into new branch)
更新fork Github(Update the fork Github)
如何更新github上的分支[复制](How to update a fork on github [duplicate])
如何从原始仓库更新github fork?(How do I update a github fork from the original repo?)
如何更新从单个fork生成的多个github项目?(Howto update multiple github projects generated from a single fork?)
相关文章
更多Python内建函数(B)
出类拔萃的爆笑逗B
谈B2B电商平台与大数据
三表连接a,b,c a和b先内连接,再和c外连接,该怎么写
0A\B2B\ERP\O2O\B2C 第三方微信、微博开发
B - Encoded Love-letter 字符串的处理
CHD4B1(hadoop-0.23)实现NameNode HA安装配置
cdh4b1之HDFS的HA(High Availability)原理简介
探索 Python,第 1 部分: Python 的内置数值类型
python2和python3的区别
最新问答
更多如何在Laravel 5.2中使用paginate与关系?(How to use paginate with relationships in Laravel 5.2?)
linux的常用命令干什么用的
由于有四个新控制器,Auth刀片是否有任何变化?(Are there any changes in Auth blades due to four new controllers?)
如何交换返回集中的行?(How to swap rows in a return set?)
在ios 7中的UITableView部分周围绘制边界线(draw borderline around UITableView section in ios 7)
使用Boost.Spirit Qi和Lex时的空白队长(Whitespace skipper when using Boost.Spirit Qi and Lex)
Java中的不可变类(Immutable class in Java)
WordPress发布查询(WordPress post query)
如何在关系数据库中存储与IPv6兼容的地址(How to store IPv6-compatible address in a relational database)
是否可以检查对象值的条件并返回密钥?(Is it possible to check the condition of a value of an object and JUST return the key?)
Copyright ©2023 peixunduo.com All Rights Reserved.粤ICP备14003112号
本站部分内容来源于互联网,仅供学习和参考使用,请莫用于商业用途。如有侵犯你的版权,请联系我们(neng862121861#163.com),本站将尽快处理。谢谢合作!