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])[2022-06-08]
在您当地的“克隆儿童”中,从父母拉出,如果您喜欢,将其添加为远程: cd child git remote add parentgit pull parent 父母的网址可能是公开的github repo,或者是您的本地克隆 - 本地克隆当然会更快。 如果你想拉一个分支,而不是父回调的当前HEAD,只需添加一个参数(例如git pull parent topic-branch )。 如果这是一次性,你可以跳过添加远程: git pull [branch ... -
在您的分支存储库的本地克隆中,您可以将原始的GitHub存储库添加为“远程”。 (“Remotes”)就像是存储库的URL的昵称 - 例如origin是一个。)然后,您可以从该上游存储库获取所有分支,并重新调整工作以继续在上游版本上工作。 在命令可能看起来像: # Add the remote, call it "upstream": git remote add upstream https://github.com/whoever/whatever.git # Fetch all the branc ...
-
我没有内幕消息,所以这可能是一个错过的功能,将在某些时候删除。 直到那时: 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])[2022-04-07]
$ 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 theiru ... -
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 never p ...
-
Github:分成新的分支(Github: fork into new branch)[2024-02-02]
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功能,它是分支: b ... -
更新fork Github(Update the fork Github)[2023-12-04]
将原始回购作为第二个远程添加到您的本地回购: git remote add parentrepo从中获取所有分支: git fetch parentrepo 鉴于你所说的, git branch -a应该给(假设你有fork的别名,因为它是克隆时默认的) * master origin/master origin/a origin/b parentrepo/a parentrepo/b parentrepo/c parentrepo/d parentrepo/e 您可以像在原产地一样从本 ... -
从您的本地项目文件夹中的终端...(并且您已经为您的叉子配置了远程 ) 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 upstre ...
-
我有同样的疑问,并在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-to-o ...
-
如何更新从单个fork生成的多个github项目?(Howto update multiple github projects generated from a single fork?)[2022-05-09]
创建新项目 在Github上创建新的存储库。 不要克隆 使用新项目名称将具有名为upstream远程的远程克隆到文件夹中 git clone -o upstream https://github.com// .git 添加新的存储库URL远程origin ,推送和设置为跟踪 cd git remote add origin https://github.com/ / 相关文章
更多- 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的区别
最新问答
更多- Runnable上的NetworkOnMainThreadException(NetworkOnMainThreadException on Runnable)
- C ++ 11 + SDL2 + Windows:多线程程序在任何输入事件后挂起(C++11 + SDL2 + Windows: Multithreaded program hangs after any input event)
- AccessViolationException未处理[VB.Net] [Emgucv](AccessViolationException was unhandled [VB.Net] [Emgucv])
- 计算时间和日期差异(Calculating Time and Date difference)
- 以编程方式标签NSMutableAttributedString swift 4(Label NSMutableAttributedString programmatically swift 4)
- C#对象和代码示例(C# objects and code examples)
- 在python中是否有数学nCr函数?(Is there a math nCr function in python? [duplicate])
- 检索R中列的最大值和第二个最大值的行名(Retrieve row names of maximum and second maximum values of a column in R)
- 给定md5哈希时如何查找特定文件(How to find specific file when given md5 Hash)
- Python字典因某些原因引发KeyError(Python Dictionary Throwing KeyError for Some Reason)
- 如何让Joomla停止打开新标签中的每个链接?(How do I get Joomla to stop opening every link in a new tab?)
- DNS服务器上的NS记录不匹配(Mismatched NS records at DNS server)
- Python屏幕捕获错误(Python screen capture error)
- 如何在帧集上放置div叠加?(How to put a div overlay over framesets?)
- 页面刷新后是否可以保留表单(html)内容数据?(Is it possible to retain the form(html) content data after page refreshed?)
- 使用iTeardownMyAppFrame和iStartMyAppInAFrame在OPA5测试中重新启动应用程序超时(Restart app within OPA5 test using iTeardownMyAppFrame and iStartMyAppInAFrame timed out)
- 自动拆分文本内容到列(Automatically splitting text content into even columns)
- 在r中的循环中将模型名称分配给gbm.step(assigning model names to gbm.step in loop in r)
- 昆明哪里有电脑等级考试二级C培训?
- C ++模板实例化,究竟是什么意思?(C++ template instantiation, what exactly does it mean?)
- 帮助渲染来自fields_for的部分内容(Help to render a partial from fields_for)
- 将url.action作为json对象返回mvc(return url.action as json object mvc)
- 使用.BAT中的.application文件类型运行ac#Console App(Run a c# Console App with .application file type from a .BAT)
- 将bindingRedirect添加到.Net标准库(Adding a bindingRedirect to a .Net Standard library)
- Laravel版本升级会影响您的控制器吗?(Laravel version upgrade affects your controller?)
- imaplib.error:命令SEARCH在状态AUTH中非法,只允许在SELECTED状态(imaplib.error: command SEARCH illegal in state AUTH, only allowed in states SELECTED)
- 如何在eclipse debug impala前端
- 如何通过Ajax API处理多个请求?(How to handle multiple requests through an Ajax API? [closed])
- 使用Datetime索引来分析数据框数据(Using Datetime indexing to analyse dataframe data)
- JS 实现一个菜单效果