9 月 152020
 
# -*- coding:utf-8 -*-
#指定字符集
file = open('C:/Users/harveymei/Desktop/newfile.txt','w')
file.write('将内容写入文件')
#在Windows的文件系统路径中,应当使用/斜线而不是\斜线
#打开一个文件,如果不存在就创建,对文件执行写入
PS C:\Users\harveymei> & C:/Users/harveymei/AppData/Local/Programs/Python/Python38/python.exe c:/Users/harveymei/hello.py
PS C:\Users\harveymei> cat C:/Users/harveymei/Desktop/newfile.txt
将内容写入文件
PS C:\Users\harveymei>

 Leave a Reply

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

(required)

(required)