Advertisement
Guest User

Untitled

a guest
Aug 20th, 2018
163
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.95 KB | None | 0 0
  1.  
  2. Jupyter Notebook
  3. Untitled3-Copy1 Last Checkpoint: минуту назад (autosaved) Current Kernel Logo
  4.  
  5. Python 3
  6.  
  7. File
  8. Edit
  9. View
  10. Insert
  11. Cell
  12. Kernel
  13. Widgets
  14. Help
  15.  
  16. from skimage.io import imread, imshow,imsave
  17.  
  18. img = imread("d:\image.jpg")
  19.  
  20. img.shape
  21.  
  22. (416, 625, 3)
  23.  
  24. imshow(img)
  25.  
  26. C:\Users\Student\Anaconda3\lib\site-packages\skimage\io\_plugins\matplotlib_plugin.py:51: FutureWarning: Conversion of the second argument of issubdtype from `float` to `np.floating` is deprecated. In future, it will be treated as `np.float64 == np.dtype(float).type`.
  27. out_of_range_float = (np.issubdtype(image.dtype, np.float) and
  28.  
  29. <matplotlib.image.AxesImage at 0x175a05d8668>
  30.  
  31. for x in range(350):
  32.  
  33. for y in range(450):
  34.  
  35. img[x,y]=[255,255,255]
  36.  
  37. import random
  38.  
  39. key = [random.randint(0,255) for i in range(100)]
  40.  
  41. for i in range(len(img)):
  42.  
  43. img[i]=img[i]- key[i % len(key)]
  44.  
  45. i= imshow(img)
  46.  
  47. C:\Users\Student\Anaconda3\lib\site-packages\skimage\io\_plugins\matplotlib_plugin.py:51: FutureWarning: Conversion of the second argument of issubdtype from `float` to `np.floating` is deprecated. In future, it will be treated as `np.float64 == np.dtype(float).type`.
  48. out_of_range_float = (np.issubdtype(image.dtype, np.float) and
  49.  
  50. #для всего цикла подставляем кеу, как меряем коробком мост
  51.  
  52. for i in range(len(img)):
  53.  
  54. img[i]=img[i]+ key[i % len(key)]
  55.  
  56. i= imshow(img)
  57.  
  58. C:\Users\Student\Anaconda3\lib\site-packages\skimage\io\_plugins\matplotlib_plugin.py:51: FutureWarning: Conversion of the second argument of issubdtype from `float` to `np.floating` is deprecated. In future, it will be treated as `np.float64 == np.dtype(float).type`.
  59. out_of_range_float = (np.issubdtype(image.dtype, np.float) and
  60.  
  61. import threading
  62.  
  63. import time
  64.  
  65.  
  66. def worker(number):
  67.  
  68. sleep_time = 1 #randon.randint(1,5)
  69.  
  70. time.sleep(sleep_time)
  71.  
  72. print(sleep_time,'--',number)
  73.  
  74. worker(1)
  75.  
  76. 1 -- 1
  77.  
  78.  
  79.  
  80. threads =[]
  81.  
  82. for i in range(5):
  83.  
  84. t = threading.Thread(target = worker, args=(i,))
  85.  
  86. threads.append(t)
  87.  
  88. t.start()
  89.  
  90.  
  91.  
  92. 1 --1 -- 1
  93. 4
  94. 11 -- 2
  95. -- 3
  96. 1 -- 0
  97.  
  98. name=['ivan','petr','Igraaaagim']
  99.  
  100. for i in name:
  101.  
  102. print('my name is',i)
  103.  
  104. my name is ivan
  105. my name is petr
  106. my name is Igraaaagim
  107.  
  108. import os
  109.  
  110. #[-1] обращение к последнему элементу вне зависимости от длинны
  111.  
  112. [i for i in os.listdir() if i.split('.')[-1]== 'jpg']
  113.  
  114. ['cat.jpg',
  115. 'img.jpg',
  116. 'img1111111.jpg',
  117. 'kinogoim0.jpg',
  118. 'kinogoim1.jpg',
  119. 'kinogoim10.jpg',
  120. 'kinogoim11.jpg',
  121. 'kinogoim12.jpg',
  122. 'kinogoim13.jpg',
  123. 'kinogoim14.jpg',
  124. 'kinogoim15.jpg',
  125. 'kinogoim16.jpg',
  126. 'kinogoim17.jpg',
  127. 'kinogoim18.jpg',
  128. 'kinogoim19.jpg',
  129. 'kinogoim2.jpg',
  130. 'kinogoim20.jpg',
  131. 'kinogoim21.jpg',
  132. 'kinogoim3.jpg',
  133. 'kinogoim4.jpg',
  134. 'kinogoim5.jpg',
  135. 'kinogoim6.jpg',
  136. 'kinogoim7.jpg',
  137. 'kinogoim8.jpg',
  138. 'kinogoim9.jpg']
  139.  
  140. #поиск всех папок
  141.  
  142. [i for i in os.listdir() if i.split('.')[-1]== i]
  143.  
  144. ['3D Objects',
  145. 'Anaconda3',
  146. 'AppData',
  147. 'Application Data',
  148. 'cat_jump_l',
  149. 'cat_jump_r',
  150. 'cat_run_l',
  151. 'cat_run_r',
  152. 'cat_stay_l',
  153. 'cat_stay_r',
  154. 'Contacts',
  155. 'Cookies',
  156. 'Desktop',
  157. 'Documents',
  158. 'Downloads',
  159. 'eclipse',
  160. 'eclipse-workspace',
  161. 'Favorites',
  162. 'IntelGraphicsProfiles',
  163. 'Links',
  164. 'Local Settings',
  165. 'Music',
  166. 'NetHood',
  167. 'OneDrive',
  168. 'Pictures',
  169. 'PrintHood',
  170. 'PycharmProjects',
  171. 'Recent',
  172. 'Saved Games',
  173. 'Searches',
  174. 'SendTo',
  175. 'Videos',
  176. 'главное меню',
  177. 'Мои документы',
  178. 'Шаблоны']
  179.  
  180. #дз функция, рекурсивно обходящая дерево файлов
  181.  
  182. a=[112.txt]
  183.  
  184. File "<ipython-input-32-5958a1a15e18>", line 1
  185. a=[112.txt]
  186. ^
  187. SyntaxError: invalid syntax
  188.  
  189.  
  190. #работа с email
  191.  
  192. import smtplib
  193.  
  194. from email.mime.text import MIMEText
  195.  
  196.  
  197. msg = MIMEText("just text") #содержание сообщения
  198.  
  199. msg['Subject'] = 'The contents of %s' % "just text"#название сообщения
  200.  
  201. msg['From'] = "bkozlovsky@bk.ru"
  202.  
  203. msg['To'] = "bkozlovsky@bk.ru"
  204.  
  205. s = smtplib.SMTP('smtp.gmail.com',587)
  206.  
  207. s.starttls()
  208.  
  209. s.login("bkozlovsky@bk.ru", "gd0d469s")
  210.  
  211. s.sendmail("bkozlovsky@bk.ru", ["bkozlovsky@bk.ru"], msg.as_string())
  212.  
  213. s.quit()
  214.  
  215. ---------------------------------------------------------------------------
  216. SMTPAuthenticationError Traceback (most recent call last)
  217. <ipython-input-38-86e0c0d72e09> in <module>()
  218. 9 s = smtplib.SMTP('smtp.mail.ru',587)
  219. 10 s.starttls()
  220. ---> 11 s.login("bkozlovsky@bk.ru", "gd0d469s")
  221. 12 s.sendmail("bkozlovsky@bk.ru", ["bkozlovsky@bk.ru"], msg.as_string())
  222. 13 s.quit()
  223.  
  224. ~\Anaconda3\lib\smtplib.py in login(self, user, password, initial_response_ok)
  225. 728
  226. 729 # We could not login successfully. Return result of last attempt.
  227. --> 730 raise last_exception
  228. 731
  229. 732 def starttls(self, keyfile=None, certfile=None, context=None):
  230.  
  231. ~\Anaconda3\lib\smtplib.py in login(self, user, password, initial_response_ok)
  232. 719 (code, resp) = self.auth(
  233. 720 authmethod, getattr(self, method_name),
  234. --> 721 initial_response_ok=initial_response_ok)
  235. 722 # 235 == 'Authentication successful'
  236. 723 # 503 == 'Error: already authenticated'
  237.  
  238. ~\Anaconda3\lib\smtplib.py in auth(self, mechanism, authobject, initial_response_ok)
  239. 640 if code in (235, 503):
  240. 641 return (code, resp)
  241. --> 642 raise SMTPAuthenticationError(code, resp)
  242. 643
  243. 644 def auth_cram_md5(self, challenge=None):
  244.  
  245. SMTPAuthenticationError: (435, b'Unable to authenticate at present:')
  246.  
  247. text1 ="""#работа с email
  248.  
  249. import smtplib
  250.  
  251. from email.mime.text import MIMEText
  252.  
  253.  
  254. msg = MIMEText("just text") #содержание сообщения
  255.  
  256. msg['Subject'] = 'The contents of %s' % "just text"#название сообщения
  257.  
  258. msg['From'] = "bkozlovsky@bk.ru"
  259.  
  260. msg['To'] = "bkozlovsky@bk.ru"
  261.  
  262. s = smtplib.SMTP('smtp.gmail.com',587)
  263.  
  264. s.starttls()
  265.  
  266. s.login("bkozlovsky@bk.ru", "gd0d469s")
  267.  
  268. s.sendmail("bkozlovsky@bk.ru", ["bkozlovsky@bk.ru"], msg.as_string())
  269.  
  270. s.quit()"""
  271.  
  272. # получение писем
  273.  
  274.  
  275.  
  276. import imaplib
  277.  
  278. msrvr = imaplib.IMAP4_SSL('imap.mail.ru',993)
  279.  
  280. msrvr.login("bkozlovsky@bk.ru", "gd0d469ss")
  281.  
  282. msrvr.select("inbox")
  283.  
  284. stat, cnt = msrvr.search(None, "ALL")
  285.  
  286. stat, data = msrvr.fetch(cnt[0].split()[-1],"(RFC822)")
  287.  
  288. msrvr.close()
  289.  
  290. msrvr.logout()
  291.  
  292.  
  293.  
  294. ('BYE', [b'logging out'])
  295.  
  296. import email
  297.  
  298. mail = email.message_from_bytes(data[0][1], \
  299.  
  300. _class = email.message.EmailMessage)
  301.  
  302. print(mail.get_payload(None, True).decode("utf-8"))
  303.  
  304. import smtplib
  305. from email.mime.text import MIMEText
  306.  
  307. msg = MIMEText("just text") #содержание сообщения
  308. msg['Subject'] = 'The contents of %s' % "just text"#название сообщения
  309. msg['From'] = "bkozlovsky@bk.ru"
  310. msg['To'] = "bkozlovsky@bk.ru"
  311. s = smtplib.SMTP('smtp.mail.ru', 587)
  312. s.starttls()
  313. s.login("bkozlovsky@bk.ru", "gd0d469s")
  314. s.sendmail("bkozlovsky@bk.ru", ["bkozlovsky@bk.ru"], msg.as_string())
  315. s.quit()
  316.  
  317.  
  318.  
  319. for i in range(113):
  320.  
  321. print('start{}',i)
  322.  
  323. start{} 0
  324. start{} 1
  325. start{} 2
  326. start{} 3
  327. start{} 4
  328. start{} 5
  329. start{} 6
  330. start{} 7
  331. start{} 8
  332. start{} 9
  333. start{} 10
  334. start{} 11
  335. start{} 12
  336. start{} 13
  337. start{} 14
  338. start{} 15
  339. start{} 16
  340. start{} 17
  341. start{} 18
  342. start{} 19
  343. start{} 20
  344. start{} 21
  345. start{} 22
  346. start{} 23
  347. start{} 24
  348. start{} 25
  349. start{} 26
  350. start{} 27
  351. start{} 28
  352. start{} 29
  353. start{} 30
  354. start{} 31
  355. start{} 32
  356. start{} 33
  357. start{} 34
  358. start{} 35
  359. start{} 36
  360. start{} 37
  361. start{} 38
  362. start{} 39
  363. start{} 40
  364. start{} 41
  365. start{} 42
  366. start{} 43
  367. start{} 44
  368. start{} 45
  369. start{} 46
  370. start{} 47
  371. start{} 48
  372. start{} 49
  373. start{} 50
  374. start{} 51
  375. start{} 52
  376. start{} 53
  377. start{} 54
  378. start{} 55
  379. start{} 56
  380. start{} 57
  381. start{} 58
  382. start{} 59
  383. start{} 60
  384. start{} 61
  385. start{} 62
  386. start{} 63
  387. start{} 64
  388. start{} 65
  389. start{} 66
  390. start{} 67
  391. start{} 68
  392. start{} 69
  393. start{} 70
  394. start{} 71
  395. start{} 72
  396. start{} 73
  397. start{} 74
  398. start{} 75
  399. start{} 76
  400. start{} 77
  401. start{} 78
  402. start{} 79
  403. start{} 80
  404. start{} 81
  405. start{} 82
  406. start{} 83
  407. start{} 84
  408. start{} 85
  409. start{} 86
  410. start{} 87
  411. start{} 88
  412. start{} 89
  413. start{} 90
  414. start{} 91
  415. start{} 92
  416. start{} 93
  417. start{} 94
  418. start{} 95
  419. start{} 96
  420. start{} 97
  421. start{} 98
  422. start{} 99
  423. start{} 100
  424. start{} 101
  425. start{} 102
  426. start{} 103
  427. start{} 104
  428. start{} 105
  429. start{} 106
  430. start{} 107
  431. start{} 108
  432. start{} 109
  433. start{} 110
  434. start{} 111
  435. start{} 112
  436.  
  437. ДЗ
  438.  
  439. 1первое-обработчик сообщений
  440.  
  441. 2 парсит почту, найдя письмо, запускает аудио ттс
  442.  
  443.  
  444.  
  445.  
  446.  
  447.  
  448.  
  449.  
  450.  
  451.  
  452.  
  453.  
  454.  
  455.  
  456.  
  457.  
  458.  
  459.  
  460.  
  461.  
  462.  
  463.  
  464.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement