获取文件路径 and Text-processing
获取文件路径
import os
>>> os.getcwd()
'C:\\Users\\chris\\AppData\\Local\\Programs\\Python\\Python36-32'
>>> os.chdir()
Traceback (most recent call last):
File "<pyshell#2>", line 1, in <module>
os.chdir()
TypeError: Required argument 'path' (pos 1) not found
>>> os.chdir('../../../../../../chris/Desktop')
>>> os.getcwd()
'C:\\Users\\chris\\Desktop'
Text-processing
data = open('note.txt')
for each_line in data:
(role, line_spoken) = each_line.split(':',1)
print (role, end='')
print ('said:', end='')
print (line_spoken, end='')
data.close()
行走感受清淡美,快步的小风

浙公网安备 33010602011771号