1 name = "吴彦祖" 2 for i in name: 3 i_by = bytes(i, encoding = "utf-8") 4 for i_bin in i_by: 5 i_b = bin(i_bin) 6 print(i_b) 输出结果: 0b10110100 0b10100110 0b10010110 我们来详细解读每个转换步骤:for i in name: 通过for循环获取所有的字符i,共获取了3个字符 i_by = bytes(i, enc
先看不加锁的: #coding=utf-8from multiprocessing import Process,Lockimport time def l(num): #lock.acquire() #stime.sleep(2) print "Hello num:%s" %num #lock.release() if __name__=='__main__': lock=Lock() for num in range(10):
配置环境:python 3.6 python编辑器:pycharm 整理成代码如下: #!/usr/bin/env python #-*- coding: utf-8 -*- #九九乘法表 #分析:九九乘法表排列呈现的是一个边长为九的直角三角形.从左到右横向是呈线性叠加的.所以用for循环来写 print(u'开始打印9x9的乘法表格') for i in range(1,10): for j in range(1,i+1): print('%dx%d=%s ' %(j,i,i*j), end=