劉任昌python寫入write讀出read文字檔

space, slash, backslash, cr = ' ', '/', '\\', '\n'
k = input("輸入三角形邊長: ")
m = input('輸入橫向規模: ')
k ,m = int(k), int(m) #將字串改成integer
f = open("杜老爺.txt",'w',encoding="utf8")
handsome = '劉任昌大烏龜'+cr
f.write(handsome)
for i in range(1, k+1):#一列i
    for ii in range(m):
        for j in range(k-i):
            f.write(space)
        f.write(slash)
        for j in range(2*i-2):
            f.write(space)
        f.write(backslash)
        for j in range(k-i):
            f.write(space)
    f.write('\n') #換列cr='\n'
for i in range(1, k+1):
    for ii in range(m):
        for j in range(i-1):
            f.write(space)
        f.write(backslash)
        for j in range(2*k-2*i):
            f.write(space)
        f.write(slash)
        for j in range(i-1):
            f.write(space)
    f.write(cr)
f.close()

留言

  1. https://kevin124574811.blogspot.com/2024/03/blog-post.html

    回覆刪除
    回覆
    1. 很優秀!繼續學習,醞釀你的能力與熱量,自然散發照亮全宇宙。

      刪除
  2. https://ccp19890604.blogspot.com/2024/03/blog-post.html

    回覆刪除
  3. https://the-most-beeaut.blogspot.com/2024/03/blog-post_20.html

    回覆刪除
  4. https://sushshshaq119.blogspot.com/2024/03/pythonwriteread.html

    回覆刪除
  5. https://the-most-great-hsing-tsen.blogspot.com/2024/03/avascriptjavapython.html

    回覆刪除
  6. https://www.blogger.com/blog/post/edit/preview/3547881648565850775/4746774717722193650

    回覆刪除
  7. https://11217133.blogspot.com/2024/03/0321.html

    回覆刪除
  8. https://ruubyy0.blogspot.com/2024/03/pythonwriteread.html

    回覆刪除
  9. https://supocheng25.blogspot.com/2024/03/blog-post_20.html

    回覆刪除
  10. https://huilii.blogspot.com/2024/03/pythonwriteread.html

    回覆刪除
    回覆
    1. 要用原始大小呈現截圖,盡可能減少空白。

      刪除
  11. https://willy2005940612.blogspot.com/2024/03/pythonwriteread.html

    回覆刪除
  12. https://kai2424.blogspot.com/2024/03/pythonwriteread.html

    回覆刪除
  13. https://xi-xbox-mmi.blogspot.com/2024/03/pythonwriteread.html

    回覆刪除
  14. https://meimei20041026.blogspot.com/2024/03/blog-post_20.html

    回覆刪除
  15. https://s10655075.blogspot.com/2024/03/pythonwriteread.html

    回覆刪除
  16. https://yrye4312311.blogspot.com/2024/03/pythonwriteread.html

    回覆刪除
  17. https://xuangreat.blogspot.com/2024/03/youtube-video-player.html

    回覆刪除
  18. https://hsiao-yu0711.blogspot.com/2024/03/pythonwriteread.html

    回覆刪除
  19. https://fanyahui.blogspot.com/2024/03/pythonwriteread.html

    回覆刪除
  20. https://euhffh822.blogspot.com/2024/03/pythonwriteread.html

    回覆刪除
  21. https://manranwen.blogspot.com/2024/03/blog-post.html

    回覆刪除
  22. https://earnest-person.blogspot.com/2024/03/blog-post.html

    回覆刪除
  23. https://the-most-great-tony11.blogspot.com/2024/03/pythonwriteread.html

    回覆刪除
  24. https://kungyuting.blogspot.com/2024/03/blog-post.html

    回覆刪除
  25. https://chyuu126.blogspot.com/2024/03/pythonwriteread.html

    回覆刪除
  26. https://themostgreatteacher.blogspot.com/2024/03/pythonwriteread.html

    回覆刪除
  27. https://the-most-great.blogspot.com/2024/03/blog-post.html

    回覆刪除

張貼留言

這個網誌中的熱門文章

劉任昌大語言模型協助收集簡報的資料

劉任昌w3schools學習ASCII, Emoji與Javascript迴圈

劉任昌HTML,CSS,樣式style,嵌入iframe