#全排列
#arr 减一个元素,放入new_arr中
def allpai(arr,new_arr):
if len(new_arr)==4:
print(new_arr)
return
for i in range(len(arr)):
temp_new=new_arr+[arr[i]]
temp_arr=arr[:i]+ arr[i+1:]
allpai(temp_arr,temp_new)
......................
阅读全部
|
qunxingw
贴于 2021年1月11日 09:58
hide
bbsi
import random
'''
实现一个猜数字小游戏,随机生成一个0~100以内的数据,由玩家来猜
每次猜完之后计算机告诉玩家是猜大了还是猜小了
共5次机会,5次猜不出来宣布游戏失败。
'''
class GuessNum:
......................
阅读全部
|
SunCZ
贴于 2020年11月9日 18:24
hide
bbsi
#测试一个列表的for循环
#测试1
#深入的研究for循环你会发现,其实是程序每执行一次in后面的变量,并提取每次执行该变量中执行N次的字符位置。
zxc='a','b','c'
for i in zxc:
print(zxc)
#当打印in后面的变量时,print会显示出该变量的(字符所含有的总位数或元素数量*字符本身)
('a', 'b', 'c')
('a', 'b', 'c')
('a', 'b', 'c')
#因为是3个字符,所以打印3次,当打印变量i时,for语句是按zxc中的总元素数量来执行的,而每执行一次,就会提取其中第N个元素。
......................
阅读全部
|
qq935599717
贴于 2020年9月17日 04:50
hide
bbsi
#参考资料https://www.jb51.net/article/178869.htm
#修改python运行路径
#路径加载连接的三种方式:'/'、 ‘\' 、 r''
import os
os.chdir('C:/Users/86177/Desktop')
os.chdir(r'C:\Users\86177\Desktop')
os.chdir('C:\\Users\\86177\\Desktop')
#获得当前python程序运行路径
import os
print(os.getced())
#输出结果为:‘C:\Users\86177\Desktop'(当前程序在的路径)
......................
阅读全部
|
qq935599717
贴于 2020年9月14日 07:19
hide
bbsi
import os
files = os.listdir()
for file in files:
print(file, os.path.isdir(file))
阅读全部
|
qq935599717
贴于 2020年9月14日 07:05
hide
bbsi
武器\n")
# 练习一下循环的使用
for i in range(1, 21):
print("我爱编程中国 {0} 次".format(i))
阅读全部
|
孔三十六
贴于 2020年9月6日 17:14
hide
bbsi
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time : 2019-01-20 22:23
# @Author : Apull
# @File : 佩奇.py
from turtle import *
def nose(x, y): # 鼻子
penup() # 提起笔
goto(x, y) # 定位
pendown() # 落笔,开始画
......................
阅读全部
|
apull
贴于 2020年8月9日 12:19
hide
bbsi