久久久久久久视色,久久电影免费精品,中文亚洲欧美乱码在线观看,在线免费播放AV片

<center id="vfaef"><input id="vfaef"><table id="vfaef"></table></input></center>

    <p id="vfaef"><kbd id="vfaef"></kbd></p>

    
    
    <pre id="vfaef"><u id="vfaef"></u></pre>

      <thead id="vfaef"><input id="vfaef"></input></thead>

    1. 站長資訊網(wǎng)
      最全最豐富的資訊網(wǎng)站

      python如何創(chuàng)建txt文件并寫入

      python創(chuàng)建txt文件并寫入的方法:首先開始寫【#!/usr/bin/python】,并設(shè)定編碼格式;然后建立txt文檔,并在里面寫文字;最后打開文檔即可。

      python如何創(chuàng)建txt文件并寫入

      本教程操作環(huán)境:windows7系統(tǒng)、python3.9版,DELL G3電腦。

      python創(chuàng)建txt文件并寫入的方法:

      1、打開python的編譯器;

      我用的python是Anaconda整合的python3的版本對應(yīng)的編譯器:spyder。

      python如何創(chuàng)建txt文件并寫入

      2、開端就寫:

      #!/usr/bin/python

      這就像是一句開場白。

      python如何創(chuàng)建txt文件并寫入

      3、既然需要輸出中文,那么就需要設(shè)定編碼格式:

      # -*- coding:utf-8 -*-

      python如何創(chuàng)建txt文件并寫入

      4、用python在文件夾a里面,建立一個b.txt文檔:

      file = open('C:/Users/Administrator/Desktop/a/b.txt','w')

      'w'表示這個文檔可以編輯,就是可讀可寫的意思。

      python如何創(chuàng)建txt文件并寫入

      5、在里面寫文字:

      file.write('你好,n  世界。')

      其中,n是換行符。

      python如何創(chuàng)建txt文件并寫入

      6、整體代碼如下:

      #!/usr/bin/python # -*- coding:utf-8 -*- file = open('C:/Users/Administrator/Desktop/a/b.txt','w') file.write('你好,n  世界。')

      而此時,a文件夾里面已經(jīng)有了一個b.txt文檔。

      python如何創(chuàng)建txt文件并寫入

      7、打開這個文檔,可以看到內(nèi)容如下圖所示。

      python如何創(chuàng)建txt文件并寫入

      相關(guān)免費學(xué)習(xí)推薦:python視頻教程

      贊(0)
      分享到: 更多 (0)
      網(wǎng)站地圖   滬ICP備18035694號-2    滬公網(wǎng)安備31011702889846號