Pihtija

Python v3

Mar 26th, 2019
45
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.06 KB | None | 0 0
  1. import time
  2. import calendar
  3. import os
  4.  
  5. # print(time.time())
  6. #
  7. # print(time.ctime(time.time()))
  8. #
  9. # strVreme=time.strftime("%Y.%m.%d %H:%M:%S %j", time.gmtime(time.time()))
  10. #
  11. # print(strVreme)
  12. #
  13. # c=calendar.calendar(2019)
  14. #
  15. #
  16. # mesec=calendar.month(2019,3)
  17. #
  18. # time.sleep(5)
  19. #
  20. #
  21. # print(mesec)
  22.  
  23. if not os.path.exists("dir1/dir2"):
  24. os.mkdir("dir1/dir2")
  25.  
  26. print (os.listdir("dir1"))
  27.  
  28. os.rmdir("dir1/dir2")
  29.  
  30. f=open("dir1/dat1.txt", "a+")
  31.  
  32. f.write("Neki Strngic bby\n")
  33.  
  34. #f=open("dir1/dat1.txt", "ab+")
  35. #f.write(b"Neki Strngic bby\n") binarno
  36.  
  37. print (f.tell())
  38.  
  39. f.seek(0,0) #druga vrednost odakle krece pomeraj, 0 od pochetka, 1 od trenuttne pozicije, 2 od kraja dokumenta
  40.  
  41. sadrzaj=f.read() #vrednost u zagradi znachi koliko chita, bez parametra - koliko moze
  42.  
  43. #sadrzaj=f.readline() chita liniju, i svaki sledeci poziv prebacuje u sledecu liniju
  44. #sadrzaj=f.readlines() vraca ceo sadrzaj kao listu
  45.  
  46. print(sadrzaj)
  47.  
  48. #print(sadrzaj.decode("UTF-8")) za binarno
  49.  
  50.  
  51. f.flush()
  52. f.close
  53.  
  54. ----------------------------------------------------------------------
  55.  
  56. import os
  57.  
  58. meni=input("1- Unos nove arhive \n\n2- Unos novog zapisnika \n\n3- Unos sadrzaja u zapisnik \n\n4- Dodaj sadrzaj u zapisnik \n\n5- Izlistaj sve zapisnike \n\n6- Prikazi zapisnik \n\n7- Obrisi zapisnik \n\n8- Izlaz\n\n")
  59.  
  60. if meni=="1":
  61. novaArhiva=input("Unesite ime nove arhive: ")
  62. if not os.path.exists("arhive/" + novaArhiva):
  63. os.mkdir("arhive/" + novaArhiva)
  64. if not os.path.exists("arhive/"+novaArhiva):
  65. print("Arhiva nije kreirana")
  66. else:
  67. print("Arhiva kreirana")
  68. if meni=="2":
  69. novaArhiva = input("Unesite ime arhive: ")
  70. noviZapisnik=input("Unesite ime novog zapisnika: ")
  71. if not os.path.exists("arhive/" + novaArhiva + "/" + noviZapisnik + ".txt"):
  72. f=open("arhive/" + novaArhiva + "/" + noviZapisnik + ".txt", "w+")
  73. if not os.path.exists("arhive/" + novaArhiva + "/" + noviZapisnik + ".txt"):
  74. print("Zapisnik nije kreiran")
  75. else:
  76. print("Zapisnik kreiran")
  77. f.flush()
  78. f.close
  79. if meni=="3":
  80. lista=os.walk("arhive")
  81. print(lista)
  82. noviZapisnik = input("Unesite ime zapisnika: ")
  83. if not os.path.exists("arhive/" + novaArhiva + "/" + noviZapisnik + ".txt"):
  84. print("Zapisnik nepostoji")
  85. else:
  86. f=open("arhive/" + novaArhiva + "/" + noviZapisnik + ".txt", "w+")
  87. unosTexta=input("Unesite text zapisnika: ")
  88. f.write("\n" + unosTexta)
  89.  
  90. if meni=="4":
  91. novaArhiva = input("Unesite ime arhive: SREDI PRONALAZENJE SAMO PO IMENU")
  92. noviZapisnik = input("Unesite ime zapisnika: ")
  93. if not os.path.exists("arhive/" + novaArhiva + "/" + noviZapisnik + ".txt"):
  94. print("Zapisnik nepostoji")
  95. else:
  96. f = open("arhive/" + novaArhiva + "/" + noviZapisnik + ".txt", "w+")
  97. unosTexta = input("Unesite text zapisnika: ")
  98. f.write("\n" + unosTexta)
  99.  
  100. if meni=="5":
  101. x=0
  102. if meni=="6":
  103. x=0
  104. if meni=="7":
  105. x = 0
  106. if meni=="8":
  107. x=0
Add Comment
Please, Sign In to add comment