擅长:python、mysql、java
<p>试试这个方式:-在</p>
<pre><code>vowels = ['a', 'e', 'i', 'o', 'u', 'y']
with open('file2.txt') as f, open('pigOut.txt', 'w+') as out:
newPigList = []
for line in f.read().splitlines():
line = line.split()
newPigList.append(map(lambda x: x+'way' if x[0] in vowels else x[1:] + x[0] + "ay", line))
print newPigList
for data in newPigList:
out.write(str(data)+'\n')
out.seek(0)
print out.read()
</code></pre>
<p>在输出:-在</p>
^{pr2}$