部分示例程序

随机数打印,包括特殊符号:

 1 import string
 2 import random
 3 import re
 4 list = [chr(i) for i in range(65,91)] + [chr(i) for i in range(97,123)] + [ str(i) for i in range(10)] #大写字母+小写字母+数字
 5 FH = ('!','@','#','$','%','&','_') #特殊字符
 6 for f in FH:
 7     list.append(f)
 8 num = random.sample(list,4)
 9 str=''
10 value = str.join(num) #将取出的十个随机数进行重新合并
11 if not value[0].isdigit():
12   print(value)
13 
14 
15 

 

中文转二进制_1 (不是最佳 ):

 1 s=input('your name:')
 2 print(s.encode(encoding='utf8'))
 3 a=str(s.encode(encoding='utf8'))
 4 location=0
 5 letter=[]
 6 for i in a:
 7     location=location+1
 8     po=location+2
 9     if i=='x':
10         # print(a[location])
11         # print(a[location:po])
12         var=a[location:po]
13         b=bin(int(var,16))
14         letter.append(b[2:])
15 print(letter)

中文转二进制_2

1 m = "中文"
2 for i in m:
3     b = bytes(i, encoding="gbk")
4     for v in b:
5         b1 = bin(v)
6         print(b1)

 

posted @ 2017-09-04 08:13  sanithzou  阅读(127)  评论(0编辑  收藏  举报