最近把一段py2的代码转换到py3的代码,结果运行到向socket中写数据的代码部分出现了'str' does not support the buffer interface这样一个错误. 一番搜索之后,发现py3里是严格区分了str和bytes的.怎么理解str和bytes呢?你可以认为str是一段文本,比如“abcd#%$^*&”什么的,而bytes呢,是二进制的一堆0,1的比特而已.看下面的图: 可以看到str的类型是class 'str',而str.encode()以后类型是class…
一.列表list转字符串str 命令(python2.x):''.join(list) 命令(python2.x):''.join(str(s) for s in list) 其中,引号中是字符之间的分割符,如",",";","\t","*"等等 我的电脑是python3.6的,如: >>> list = [1, 2, 3, 4, 5] >>> print(''.join(str(s) fo…