劉任昌python寫入write迴圈範圍range

space, slash, backslash, cr = ' ', '/', '\\', '\n'
k = input('邊長: ') #輸入字串
m = input('橫向: ')
k, m = int(k), int(m)
f = open("難嗎.txt",'w',encoding='utf8')
f.write('劉任昌讀取檔案' + cr)#註解\n換列
for i in range(9):
    f.write(str(i))
f.write(cr)
for i in range(1, k+1):   #迴圈1到k
    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(cr)
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()

385影片

留言

  1. https://naiyuanzhang1226.blogspot.com/2024/03/pythonwriterange.html

    回覆刪除
  2. https://kuoyiting.blogspot.com/2024/03/pythonwriterange.html

    回覆刪除
  3. https://e99136.blogspot.com/2024/03/blog-post_21.html

    回覆刪除
  4. https://su-you-an.blogspot.com/2024/03/pythonwriterange.html

    回覆刪除
  5. https://chan-wan-yi.blogspot.com/2024/03/blog-post_21.html

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

    回覆刪除
  7. https://laiweikaiaaa.blogspot.com/2024/03/writerange.html

    回覆刪除
  8. https://kitty030994.blogspot.com/2024/03/pythonwriterange.html

    回覆刪除
  9. https://stanley-ouo.blogspot.com/2024/03/382-383-space-slash-backslash-cr-n-k.html

    回覆刪除
  10. https://sandy06252023.blogspot.com/2024/03/pythonwrite.html

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

    回覆刪除
  12. https://liu-guang-wei.blogspot.com/2024/03/pythonwriterange.html

    回覆刪除
  13. 作者已經移除這則留言。

    回覆刪除
  14. https://the-most-little-black.blogspot.com/

    回覆刪除
  15. https://wang-yu-jia-wangyujia.blogspot.com/2024/03/pythonwriterange.html

    回覆刪除
  16. https://guan-yu-zhu.blogspot.com/2024/03/pythonwriterange.html

    回覆刪除
  17. https://zzl1102.blogspot.com/2024/03/phthonwriterange.html

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

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

    回覆刪除
  20. https://ymo0831.blogspot.com/2024/03/pythonwriterange.html

    回覆刪除
  21. https://linchinppei.blogspot.com/2024/03/writerange.html

    回覆刪除
  22. https://chienyinghuan.blogspot.com/2024/03/pythonwriterange.html

    回覆刪除
  23. https://zhen-zhen4869.blogspot.com/2024/03/pythonwriterange.html

    回覆刪除
  24. https://wujiaqi1010.blogspot.com/2024/03/phthonwriterange.html

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

    回覆刪除
  26. https://zxnhtml.blogspot.com/2024/03/pythonwrite.html

    回覆刪除
  27. https://yang0218.blogspot.com/2024/03/space-slash-backslash-cr-n-k-input-m.html

    回覆刪除
  28. https://fgjjfufutfytfyyfyuk.blogspot.com/2024/03/pythonwriterange.html

    回覆刪除
  29. https://wnagenqiiiiiiiiiiii.blogspot.com/2024/03/pythonwriterange.html

    回覆刪除
  30. https://hank20050328.blogspot.com/2024/03/space-slash-backslash-cr-n-k-input-m.html

    回覆刪除
  31. https://li1007.blogspot.com/2024/03/pythonwriterange.html

    回覆刪除
  32. https://wuhongbing.blogspot.com/2024/06/pythonwriterange.html

    回覆刪除

張貼留言

這個網誌中的熱門文章

劉任昌python串列List(陣列Array),元組Tuple,集合Set,字典Dict

2025年3月4日上課Python 陣列array串列的函數(方法)

劉任昌Javascript物件導向Python物件導向