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
2024-03-27 21:03

满意答案

从您的本地项目文件夹中的终端...(并且您已经为您的叉子配置了远程

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])

在您当地的“克隆儿童”中,从父母拉出,如果您喜欢,将其添加为远程: cd child git remote add parent <parent-url> git pull parent 父母的网址可能是公开的github repo,或者是您的本地克隆 - 本地克隆当然会更快。 如果你想拉一个分支,而不是父回调的当前HEAD,只需添加一个参数(例如git pull parent topic-branch )。 如果这是一次性,你可以跳过添加远程: git pull <parent-url> [b...

如何更新GitHub分支库?(How do I update a GitHub forked repository?)

在您的分支存储库的本地克隆中,您可以将原始的GitHub存储库添加为“远程”。 (“Remotes”)就像是存储库的URL的昵称 - 例如origin是一个。)然后,您可以从该上游存储库获取所有分支,并重新调整工作以继续在上游版本上工作。 在命令可能看起来像: # Add the remote, call it "upstream": git remote add upstream https://github.com/whoever/whatever.git # Fetch all the ...

如何通过Github API从它的原始更新fork(How to update a fork from it's original via the Github API)

我没有内幕消息,所以这可能是一个错过的功能,将在某些时候删除。 直到那时: Github提供所有提交(我假设)整个fork网络; 因此,接受提交哈希的API将很乐意处理来自上游或其他分支的哈希(这明确记录为回购/提交/比较和创建提取请求 )。 因此,有两种方法只能通过API进行更新: 使用Git数据api :如果你不改变你的fork的master,这通常是最好的选择。 获取上游ref /repos/upstream/repo/git/refs/heads/master ,并从中获取哈希值 使用相同...

如何在GitHub上的别人的分支上获取分支?(How do I fetch a branch on someone else's fork on GitHub? [duplicate])

$ git remote add theirusername git@github.com:theirusername/reponame.git $ git fetch theirusername $ git checkout -b mynamefortheirbranch theirusername/theirbranch $ git remote add theirusername git@github.com:theirusername/reponame.git $ git fetch t...

叉和分支在github上的区别(difference between fork and branch on github)

GitHub上的所有分支将被复制在一个分支中。 (显然,这不包括从来没有被推到GitHub的分支。) 但是fork是一个GitHub-to-GitHub操作; 没有任何东西复制到您的电脑。 它与Git 克隆不完全相同。 如果您是要问“克隆项目时复制的内容”,请参阅git-clone(1)手册。 All branches on GitHub will be copied in a fork. (Obviously, this doesn’t include branches that were ne...

Github:分成新的分支(Github: fork into new branch)

Fork = Github上另一个用户的克隆存储库,让GitHub知道它 1)像往常一样使用fork按钮fork回购 2)如果要重命名分支 git branch -m old_branch_name new_branch_name git push origin :old_branch_name git push origin new_branch_name 如果要重命名不是分支而是整个存储库 - 请参阅如何 。 如果你想在一个存储库中同时拥有两个分支,它不是名为fork的GitHub功能,它是...

更新fork Github(Update the fork Github)

将原始回购作为第二个远程添加到您的本地回购: git remote add parentrepo <url> 从中获取所有分支: git fetch parentrepo 鉴于你所说的, git branch -a应该给(假设你有fork的别名,因为它是克隆时默认的) * master origin/master origin/a origin/b parentrepo/a parentrepo/b parentrepo/c parentrepo/d parentrepo/e 您可以像在原产...

如何更新github上的分支[复制](How to update a fork on github [duplicate])

从您的本地项目文件夹中的终端...(并且您已经为您的叉子配置了远程 ) 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 u...

如何从原始仓库更新github fork?(How do I update a github fork from the original repo?)

我有同样的疑问,并在github帮助中找到答案。 git remote add upstream git://url-to-original git fetch upstream git merge upstream/master git push upstream是我给原始存储库的名称。 希望能帮助到你。 I had the same doubt and found the answer in the github help. git remote add upstream git://url...

如何更新从单个fork生成的多个github项目?(Howto update multiple github projects generated from a single fork?)

创建新项目 在Github上创建新的存储库。 不要克隆 使用新项目名称将具有名为upstream远程的远程克隆到文件夹中 git clone -o upstream https://github.com/<user>/<fork>.git <my_new_project_name> 添加新的存储库URL远程origin ,推送和设置为跟踪 cd <my_new_project_name> git remote add origin https://github.com/<user>/<my_ne...

相关文章

更多

Python内建函数(B)

  英语水平不咋滴,翻译过程中有错误或不准确的望大家指正: ),示例都是俺在命令提示符敲的, ...

出类拔萃的爆笑逗B

1、准备下水游泳,忽然看见水中有人不停的挥手,一会沉一会起的,吓得我不敢下去了。。。妈呀,都冒泡了,这 ...

谈B2B电商平台与大数据

数据为王,服务为本——谈B2B电商平台与大数据 2013-06-27 11:10:41 作者:B ...

三表连接a,b,c a和b先内连接,再和c外连接,该怎么写

三表连接a,b,c a和b先内连接,再和c外连接,db2 该怎么写 select * from a ...

0A\B2B\ERP\O2O\B2C 第三方微信、微博开发

0A\B2B\ERP\O2O\B2C 0A\O2O\B2C(MYSQL) B2B\ERP(ORACLE ...

B - Encoded Love-letter 字符串的处理

B - Encoded Love-letter Time Limit:1000MS Memory ...

CHD4B1(hadoop-0.23)实现NameNode HA安装配置

Cloudera CHD4B1版本已经包含了NameNode HA,社区也把NameNode HA b ...

cdh4b1之HDFS的HA(High Availability)原理简介

0 引入 以前Hadoop版本中,NameNode是HDFS集群的单点故障(single po ...

探索 Python,第 1 部分: Python 的内置数值类型

Python 编程语言具有很高的灵活性,它支持多种编程方法,包括过程化的、面向对象的和函数式的。但最重 ...

python2和python3的区别

python2和python3的区别,1.性能 Py3.0运行 pystone benchmark的速 ...

最新问答

更多

如何在Laravel 5.2中使用paginate与关系?(How to use paginate with relationships in Laravel 5.2?)

请尝试以下方法: $messages = $user->contact_messages()->paginate(10); Try the following: $messages = $user->contact_messages()->paginate(10);

linux的常用命令干什么用的

linux和win7不一样,win7都图形界面,都是用鼠标来操作打开,解压,或者关闭。而linux是没有图形界面的,就和命令提示符一样的一个文本框,操作linux里的文件可没有鼠标给你用,打开文件夹或者解压文件之类的操作都要通过linux常用命令。

由于有四个新控制器,Auth刀片是否有任何变化?(Are there any changes in Auth blades due to four new controllers?)

它创建了这些视图: 'auth/login.blade.php', 'auth/register.blade.php', 'auth/passwords/email.blade.php', 'auth/passwords/reset.blade.php', 'layouts/app.blade.php', 'home.blade.php' 并修改这些文件: 'Http/Controllers/HomeController.php', 'routes/web.php' 如果使用--views

如何交换返回集中的行?(How to swap rows in a return set?)

您可以使用特殊的CASE表达式进行ORDER BY如下所示: SELECT * FROM table ORDER BY CASE id WHEN 3 THEN 8 WHEN 8 THEN 3 ELSE id END You can ORDER BY using a special CASE expression like this: SELECT * FROM table ORDER BY CASE id WHEN 3 THEN 8 WHEN 8 THEN 3 ELSE id END

在ios 7中的UITableView部分周围绘制边界线(draw borderline around UITableView section in ios 7)

我建议你制作一个新的TableView Cell,在这个newTableViewCell中,加载第2节中的所有单元格,然后为newTableViewCell提供边框。 但如果您不想这样做,那么您可以使用以下代码: @property(strong,nonatomic) CAShapeLayer* borderPath; -(void)viewDidLayoutSubviews{ [_borderPath removeFromSuperlayer]; UIView *viewToGiveBord

使用Boost.Spirit Qi和Lex时的空白队长(Whitespace skipper when using Boost.Spirit Qi and Lex)

出于一些奇怪的原因,我现在发现了一个不同的问题, Boost.Spirit SQL语法/词法分析失败 ,其中提供了一些其他解决方案来进行空格跳过。 一个更好的! 以下是根据建议重新编写的示例代码: #include #include #include #include #include #incl

Java中的不可变类(Immutable class in Java)

1.如果我只有final变量的课程? 这会让你远离但不是全部。 这些变量的类型也需要是不可变的。 考虑一下 class MyImmutableClass { // final variable, referring to a mutable type final String[] arr = { "hello" }; // ... } 这允许有人做 myImmutableObject.arr[0] = "world"; 并有效地改变你的不可变类的对象。 此外,建议禁

WordPress发布查询(WordPress post query)

如果你想要在div中包含所有帖子: post_parent) { $myposts = get_posts('numberposts=10&tag=medical&order=DESC'); echo ' '; foreach ($myposts as $post): ?>

如何在关系数据库中存储与IPv6兼容的地址(How to store IPv6-compatible address in a relational database)

我不确定哪个是MySQL的正确答案,因为它本身还不支持IPv6地址格式(尽管“ WL#798:MySQL IPv6支持 ”表明它将在MySQL v6.0中,当前文档不支持)。 不过,你建议的人建议去2 * BIGINT,但要确保他们是UNSIGNED。 在IPv6的/ 64地址边界处有一种自然分割(因为/ 64是最小的网格块大小),这将与其很好地对齐。 I'm not sure which is the right answer for MySQL given that it doesn't y

是否可以检查对象值的条件并返回密钥?(Is it possible to check the condition of a value of an object and JUST return the key?)

您可以使用Object.keys和Array#find来获取匹配value的key 。 const letters = {a:'26',b:'25',c:'24',d:'23',e:'22',f:'21',g:'20',h:'19',i:'18',j:'17',k:'16',l:'15',m:'14',n:'13',o:'12',p:'11',q:'10',r:'9',s:'8',t:'7',u:'6',v:'5',w:'4',x:'3',y:'2',z:'1'}; function sw