ITPub博客

首页 > IT职业 > IT职场 > 猜1-10的数字python脚本

猜1-10的数字python脚本

IT职场 作者:lakefront 时间:2021-09-09 09:21:41 0 删除 编辑

#!/usr/bin/python
#coding:utf-8
import random
num=random.randint(1,10)
while True:
cai=int(raw_input('请输入随机数字:'))
if cai == num:
print '猜对了'
exit()
elif cai > num:
print '猜大了'
else:
print '猜小了'

非交互式的cp脚本
#!/usr/bin/python
#coding:utf-8
import sys
file1=sys.argv[1]
file2=sys.argv[2]
x=open(file1)
y=open(file2,'w')
for i in x:
y.writelines(i)
x.close()
y.close()

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/2491/viewspace-2809692/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2019-08-05

  • 博文量
    99
  • 访问量
    625