Advertisement
TheAceHome

Untitled

May 19th, 2019
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.99 KB | None | 0 0
  1. class Goods:
  2.     def __init__(self,goods=[]):
  3.         self.goods=goods
  4.  
  5.     def __str__(self):
  6.         return str(self.goods)
  7.  
  8.     def append(self,data):
  9.         self.goods.append(data)
  10.  
  11.     def wrote(self):
  12.         for i in self.goods:
  13.             f.write(i)
  14.  
  15.     def max_price(self):
  16.         cnt=0
  17.         l=[]
  18.         for i in self.goods:
  19.             c=i.split(" ")
  20.             if cnt < int(c[3]):
  21.                 cnt =int(c[3])
  22.                 l.clear()
  23.                 l.append(i)
  24.         print(l)
  25.  
  26.     def all_companies(self):
  27.         l=[]
  28.         for i in self.goods:
  29.             c=i.split(" ")
  30.             l.append(c[2])
  31.         print(l)
  32.  
  33.     def __iter__(self):
  34.         return self
  35.    
  36.    
  37.  
  38.  
  39.  
  40. meow=open(r"C:\Users\nikit\Downloads\lrh.txt","r")
  41. texts=meow.readlines()
  42. print(texts[0])
  43. a=Goods(texts)
  44. print(a)
  45. a.append("1 2 3 4")
  46. print(a)
  47. meow.close()
  48. f=open(r"C:\Users\nikit\Downloads\asdf.txt","w")
  49. a.wrote()
  50. f.close()
  51. a.max_price()
  52. a.all_companies()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement