【爬坑】Python 3.6 在 Socket 程式設計時出現型別錯誤 TypeError: a bytes-like object is required, not 'str'
1. 問題描述
Python 3.6 在 Socket 程式設計時出現錯誤如下
Traceback (most recent call last): File "F:/share/IdeaProjects/test/mypython/test/test10_tcpclient.py", line 17, in <module> sock.send(str) TypeError: a bytes-like object is required, not 'str' Process finished with exit code 1
2. 解決方案
型別錯誤,解決方案參考 python執行tcp伺服器和客戶端
將 Client 端程式碼改為以下
sock.send(bytes(str,'utf-8'))
詳情請檢視 [Python_7] Python Socket 程式設計
相關推薦
【爬坑】Python 3.6 在 Socket 程式設計時出現型別錯誤 TypeError: a bytes-like object is required, not 39;str39;
1. 問題描述 Python 3.6 在 Socket 程式設計時出現錯誤如下 Traceback (most recent call last): File "F:/share/IdeaProjects/test/mypython/test/test10_tcpcli
【Python】TypeError: a bytes-like object is required, not 'str'
1、報錯 自己python3.+,使用別人python2.的程式碼報錯: rs = pow(int(binascii.hexlify(text), 16), int(pubKey, 16), int
Python 3.5.2 TypeError: a bytes-like object is required, not 39;str’問題解決方案
con 指定 err byte 讀取 字節 code 解決方案 錯誤 運行環境Mac Python 3.5.2 Q: http_response = """\ HTTP/1.1 200 OK Hello, World! """ client_connection.se
Socket send() method throws TypeError: a bytes-like object is required, not 39;str39;
error: ring net peer 函數 搜索 string類型 unicode 區分 python3 socket編程,發送data數據,會遇到需要bytes類型,而不是str字符串的錯誤 例如: import socket mysock = socket
Python異常:TypeError: a bytes-like object is required, not 39;str39;
Python異常:TypeError: a bytes-like object is required, not ‘str’ import json str = [{"userName" : "UserPython", "age" : 20}, (2, 3), 1] with o
Python異常:TypeError: a bytes-like object is required, not 'str'
Python異常:TypeError: a bytes-like object is required, not ‘str’ import json str = [{"userName" : "Use
【轉載】python 3.6整合安裝xadmin
安裝xadmin 通過pip進行安裝 pip install xadmin 1 安裝完成後,發現會自動把關聯的對應包給一起安裝上 ,但是在我們執行如下命令的時候會報錯: python manage.py
【紫書】例題3-6 環狀序列(Circular Sequence, ACM/ICPC Seoul 2004, UVa1584)
alt scanf tdi post audio 描述 spa log return 【題目描述】 長度為n的環狀串有n種表示法,分別為某個位置開始順時針得到。例如,圖中的環狀串有10種表示: CGAGTCAGCT,GAGTCAGCTC,AGTCAGCTCG等。在這些表示
【爬坑】Vim 文檔加密 & 解密
原來 bsp 文檔加密 ref 14. 密碼 網上 sys -s 0. 說明 在 Vim 使用過程中,最後保存的時候輸入了 :X ,提示輸入密碼,輸完密碼發現以前沒遇到類似情況。 有時候最後保存那會兒默認大寫。 在網上一查發現原來給文件加密了,就順帶搜索
【爬坑】遠端連線 MySQL 失敗
問題描述 遠端連線 MySQL 伺服器失敗 報以下錯誤 host 192.168.23.1 is not allowed to connect to mysql server 解決方案 在伺服器端開啟 MySQL 伺服器進行許可
【爬坑】一次OOM爬坑之旅
記一次 OOM 引起的爬坑之旅。 問題 測試反饋首頁在重新整理的時候有偶爾崩潰的情況,但是情況描述的不是很清楚,因為不是能一直復現的。 復現 找到測試妹子要來出問題的手機自測。根據測試的描述既然是在重新整理的時候崩潰,所以就一直重新整理首
【學習總結】Python-3-身份運算符 is 與 == 區別
學習總結 單元 opera python3 布爾值 http 菜鳥 info 學習 參考:菜鳥教程-Python3運算符 身份運算符 is 和 is not:用於比較兩個對象的存儲單元 判斷兩個標識符是不是引用自相同或不同對象,返回一個布爾值 對於“同一個對象”中的‘對
【學習總結】Python-3-風格各異的數值類型實例
image 基本數據類型 小數點 小寫 圖片 數據 友好 自動補全 .html 菜鳥教程-Python3-基本數據類型 可能是考點的各種形態的數值類型 int型:正數負數,八進制0開頭,十六進制0x開頭 float型:小數點的前後都可以沒有數字,自動補全 complex型
【踩坑】報錯 non-static method xxx() cannot be referenced from a static context
bye not ont ODB 原因 con cannot ood ren 今天測試代碼時遇到 Error:(6, 55) java: non-static method sayGoodbye() cannot be referenced from a static
【已解決】SpringMVC表單提交結果頁面出現400錯誤的可能原因分析
頁面錯誤: The server cannot or will not process the request due to something that is perceived to be a client error (e.g., malformed reques
python 3.0讀取文件出現編碼錯誤(illegal multibyte sequence )
highlight python inf 技術 uft 解決 但是 .com pre 代碼如下: myfile2=open(‘e:/enterprise.xlsx‘,mode = ‘r‘) file2_content=myfile2.readlines() print
python Bug記錄-int() argument must be a string, a bytes-like object or a number, not 39;dict39;
程式碼如下: error_msg = "" if request.method == "POST": new_dayincome = request.POST.get("dayincome_time", None) total_bath =
【那些年踩過的坑】win10 + python 3.6 環境下安裝 pytorch/torchvision
我的安裝環境和版本 Windows 10 Python 3.6 Anaconda 3 64-bit Pytorch CPU version torchvision 安裝步驟 安裝python3.6/3.5(個人用的是3.6。3.5也可以,但我沒試
【python 3.6】xlwt和xlrd對excel的讀寫操作
times python _for 一行 xlsx datetime 列數 font utf-8 #python 3.6 #!/usr/bin/env python # -*- coding:utf-8 -*- __author__ = ‘BH8ANK‘ im
【轉1】Appium 1.6.3 在Xcode 8, iOS 10.2(模擬器)測試環境搭建 經驗總結
div tar post bug span trace 版本 test 4.0 Appium 1.6.3 在Xcode 8, iOS 10.2(模擬器)測試環境搭建 經驗總結 關於 Appium 1.6.3 在Xcode 8, 10.2 的iOS模擬器上的問