擅长:python、mysql、java
<p>试试这个</p>
<pre><code>import random
def road_generator():
directions = ['n','s','w','e']
road = []
for x in range(10):
temp = random.choice(directions)
while x > 0 and temp == road[x-1]:
temp = random.choice(directions)
road.append(temp)
print(road)
</code></pre>