这是我现在的代码:
def ImportFile(FileName):
templist =[]
fileHandle = open('keywords.CSV','r') # Open the file in read only mode
# For each line in the file
for line in fileHandle:
File = line.strip() # Cleans the line of text and gets rid of newline characters etc
fileHandle_list.append(temp.split(',')) # Converts the line of text into a list of items which were seperated by ","
return fileHandle_list
''' randomise list '''
def RandomiseList():
# Go through picking an item at random until I have the whole list
fileHandle_list = []
for item in random.sample(keywords, len(keywords)):
fileHandle_list.append(item)
print(fileHandle_list)
return fileHandle_list
这是它将被放置的地方。你知道吗
我试过很多东西,但都不能用,谢谢你的帮助。你知道吗
如果您只是尝试随机排列csv文件中的行顺序,则类似于:
或者将其分离以加载列表,然后稍后再“洗牌”:
相关问题 更多 >
编程相关推荐