Giter Site home page Giter Site logo

my_python_qa_test_data's Introduction

my_python_qa_test_data

Работа с тестовыми данными

  • txt
  • csv
  • json
  • sqlite

Чтение из файла

f = open("file_name", "r")
f.read()
f.close()

Использование with

with open("file_name", "r") as f:
    f.read()

Python содержит встроенные библиотеки для работы json, csv, sqlite, html данными. А так же может быть использован для чтения любого файла в бинарном формате.

Генераторы и итераторы

Генераторы создаются путем добавления ключевого слова yield в любую функцию. После этого каждое новое обращение к ней вызывает следующую итерацию цикла или выдачу следующего значения.

def squares(start, stop):
    for i in range(start, stop):
        yield i * i

generator = squares(1, 10)
def letters():
    yield 'a'
    yield 'b'

Итераторы это более общее понятние и в общем случае означает объект который явялется наследником класса у которого реализованы методы next и iter

class Squares(object):

    def __init__(self, start, stop):
       self.start = start
       self.stop = stop

    def __iter__(self): 
        return self

    def __next__(self):
       if self.start >= self.stop:
           raise StopIteration
       current = self.start * self.start
       self.start += 1
       return current

iterator = Squares(1, 10)

my_python_qa_test_data's People

Contributors

mila8888 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.