本文介绍了python帮助获取数据,保存日期,数组,random.shuffle的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 我是comp科学的初学者,而且我的教授正在使用python,这是全新的汤姆我对程序即时写作有一些问题,我有一些问题。 简要说明 i必须做一个项目,其中有九个盒子填充数字1-8,并且1个空格是空的,游戏需要是加扰,所有的动作都需要保存。游戏可以在游戏中随时暂停。对象是将数字移动到黑点,直到它们全部有序。 网格我需要包含变量,以便玩家可以移动它们 这就是我拥有的东西,我知道它很遥远 def board(): board = [1,2 ,3,4,5,6,7,8,9] 范围内的x(0,9): print" |" ; if(board [x] == 9): print" _" else: 打印板[x] if(x == 8): print" | board() 当我运行它看起来像这样 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | _ | 这就是我需要的样子: | 1 | 2 | 3 | | 4 | 5 | 6 | | 7 | 8 | _ | 我做错了什么?另外我如何使用random.shuffle()函数,这样我可以加扰数字? 帮助会很大程度上适用... 我也将如何保存每一个动作,随机功能也不起作用,所以我可以加扰数字。 i我可能做错了制作游戏板,因为我需要一切都可以互换,当玩家想要移动并将数字放到空白点时,任何帮助任何人??? 提前多多感谢 我也似乎无法导入数组或随机 另外我的项目是附加的,如果有人不明白我需要做什么解决方案 im a beginner at comp science, and my prof is using python, which is totally new tom me i had a few questions with the program im writing, im having a few problems.brief summaryi have to do a project where there are nine boxes filled with number 1-8, and 1 space is empty, the game needs to be scrambled, also all the moves need to be saved. the game can be paused anytime during thegame. the object is to move the numbers into the black spot till they are all in order.the grid i have needs to contain variables so that can be moved by the playersthis what i have and i know it is far offdef board():board = [1,2,3,4,5,6,7,8,9]for x in range(0, 9):print "|"if(board[x]==9):print "_"else:print board[x]if(x==8):print "|"board()when i run that it looks like this|1|2|3|4|5|6|7|8|_|and this is how i need it to look:|1|2|3||4|5|6||7|8|_|what am i doing wrong? also how do i use the random.shuffle() function so i can scramble the numbers?help would be greatly appriciated...also how would i save every move, also the random fuction isnt working so i can scramble the numbers.i am probably doing everything wrong to make a game board, cause i need everything to to be interchanglable when the players wants to move and adjecent number to the blank spot, any help anyone???thanks alot ahead of timealso i can''t seem to import array or randomin addition my project is attached if anyone didnt understand what i needed to to do 解决方案 这篇关于python帮助获取数据,保存日期,数组,random.shuffle的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云! 08-23 16:42