Python字符串和随机

# -*- coding:utf-8 -*-
import random
# 判断第一个字符串是否是第二个字符串的子串
'''
strA="hello"
strB="helloWorld"
if strA in strB:
print("yes")
else:
print(no)
'''


#移位操作,判断str1是否是str2移动n位后的,需要for循环,未完成
'''
def setups(strs,setup):
print(type(setup))
setup2=setup%len(strs)
ret_str=strs[-setup2:]+strs[:-setup2]
return ret_str


str1='欢迎来到我的博客'
str=setups(str1,2)
print(str)
'''


# 随机彩票号码
'''
ssq_qian=[i for i in range(1,34)]
ssq_hou=[i for i in range(1,17)]
qian_random=random.sample(ssq_qian,k=6)
hou_random=random.sample(ssq_hou,k=1)
qian_random.sort(reverse=True)
print(qian_random)
print(hou_random)
'''


# 随机扑克牌
'''
poker_num=[str(i) for i in range(2,11)]
poker_str=['A','J','Q','K']
poker_king=['大王','小王']
poker_color=['黑','红','梅','方']
pokers=["%s%s"%(i,j) for i in poker_color for j in poker_num+poker_str] + poker_king
random.shuffle(pokers)


person_a=pokers[0:51:3]
person_b=pokers[1:51:3]
person_c=pokers[2:51:3]
last=pokers[-3:]


print(len(person_a))
print(len(person_b))
print(len(person_c))


print(last)


'''


# 快速生成二维码,这个模块在osX系统无法成功执行,Windows未试
# 先安装模块 pip3 install qrcode
import qrcode 
# 简单实例
# a = qrcode.make("http:www.baidu.com")
# a.save("百度网站二维码.png")
# 详细实例
'''
qr=qrcode.QRCode(
version=1,
error_correction=qrcode.ERROR_CORRECT_Q,
box_size=4,
border=2
)
qr.add_data("www.baidu.com")
qr.make(fit=True)
img=qr.make_image(fill_color="yellow",back_color="blue")
img.save('百度.png')
'''




  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值