ব্যবহারকারীদের বৈধ প্রতিক্রিয়া না দেওয়া পর্যন্ত ইনপুটটির জন্য জিজ্ঞাসা করা হচ্ছে


562

আমি এমন একটি প্রোগ্রাম লিখছি যা ব্যবহারকারীর কাছ থেকে একটি ইনপুট গ্রহণ করে।

#note: Python 2.7 users should use `raw_input`, the equivalent of 3.X's `input`
age = int(input("Please enter your age: "))
if age >= 18: 
    print("You are able to vote in the United States!")
else:
    print("You are not able to vote in the United States.")

ব্যবহারকারী যতক্ষণ অর্থবহ ডেটা প্রবেশ করবে ততক্ষণ প্রোগ্রামটি প্রত্যাশার সাথে কাজ করে।

C:\Python\Projects> canyouvote.py
Please enter your age: 23
You are able to vote in the United States!

ব্যবহারকারী যদি অবৈধ ডেটা প্রবেশ করে তবে এটি ব্যর্থ হয়:

C:\Python\Projects> canyouvote.py
Please enter your age: dickety six
Traceback (most recent call last):
  File "canyouvote.py", line 1, in <module>
    age = int(input("Please enter your age: "))
ValueError: invalid literal for int() with base 10: 'dickety six'

ক্রাশ হওয়ার পরিবর্তে, আমি প্রোগ্রামটি আবার ইনপুট চাইতে চাই। এটার মত:

C:\Python\Projects> canyouvote.py
Please enter your age: dickety six
Sorry, I didn't understand that.
Please enter your age: 26
You are able to vote in the United States!

সংবেদনশীল ডেটা প্রবেশ করার সময় আমি কীভাবে প্রোগ্রামটিকে ক্রাশ হওয়ার পরিবর্তে বৈধ ইনপুটগুলি জিজ্ঞাসা করতে পারি?

আমি কীভাবে এই মানগুলিকে প্রত্যাখ্যান করতে পারি -1, যা intএই প্রসঙ্গে একটি বৈধ , তবে অযৌক্তিক?

উত্তর:


703

এটি সম্পাদন করার সহজতম উপায় হ'ল inputপদ্ধতিটি কিছুক্ষণ লুপে রাখা। continueআপনি যখন খারাপ ইনপুট পান তখন এবং breakযখন আপনি সন্তুষ্ট হন তখন লুপের বাইরে যান Use

যখন আপনার ইনপুট একটি ব্যতিক্রম বাড়াতে পারে

ব্যবহারকারী কখন ডেটা প্রবেশ করতে পারে যা পার্স করা যায় না তা ব্যবহার করুন tryএবংexcept তা সনাক্ত করুন ।

while True:
    try:
        # Note: Python 2.x users should use raw_input, the equivalent of 3.x's input
        age = int(input("Please enter your age: "))
    except ValueError:
        print("Sorry, I didn't understand that.")
        #better try again... Return to the start of the loop
        continue
    else:
        #age was successfully parsed!
        #we're ready to exit the loop.
        break
if age >= 18: 
    print("You are able to vote in the United States!")
else:
    print("You are not able to vote in the United States.")

আপনার নিজস্ব বৈধকরণ বিধি কার্যকর করা

পাইথন সফলভাবে পার্স করতে পারে এমন মানগুলি আপনি যদি প্রত্যাখ্যান করতে চান তবে আপনি নিজের বৈধতা যুক্তি যুক্ত করতে পারেন।

while True:
    data = input("Please enter a loud message (must be all caps): ")
    if not data.isupper():
        print("Sorry, your response was not loud enough.")
        continue
    else:
        #we're happy with the value given.
        #we're ready to exit the loop.
        break

while True:
    data = input("Pick an answer from A to D:")
    if data.lower() not in ('a', 'b', 'c', 'd'):
        print("Not an appropriate choice.")
    else:
        break

ব্যতিক্রম হ্যান্ডলিং এবং কাস্টম বৈধকরণের সম্মিলন

উপরের দুটি কৌশলই এক লুপে একত্রিত হতে পারে।

while True:
    try:
        age = int(input("Please enter your age: "))
    except ValueError:
        print("Sorry, I didn't understand that.")
        continue

    if age < 0:
        print("Sorry, your response must not be negative.")
        continue
    else:
        #age was successfully parsed, and we're happy with its value.
        #we're ready to exit the loop.
        break
if age >= 18: 
    print("You are able to vote in the United States!")
else:
    print("You are not able to vote in the United States.")

এটি একটি কার্যক্রমে সমস্তকে আবদ্ধ করা

আপনার ব্যবহারকারীর যদি প্রচুর বিভিন্ন মানের জন্য জিজ্ঞাসা করতে হয় তবে এই কোডটি কোনও ফাংশনে রাখাই কার্যকর হতে পারে, তাই আপনাকে প্রতিবার এটি পুনরায় টাইপ করতে হবে না।

def get_non_negative_int(prompt):
    while True:
        try:
            value = int(input(prompt))
        except ValueError:
            print("Sorry, I didn't understand that.")
            continue

        if value < 0:
            print("Sorry, your response must not be negative.")
            continue
        else:
            break
    return value

age = get_non_negative_int("Please enter your age: ")
kids = get_non_negative_int("Please enter the number of children you have: ")
salary = get_non_negative_int("Please enter your yearly earnings, in dollars: ")

সবগুলোকে একত্রে রাখ

খুব জেনেরিক ইনপুট ফাংশন করতে আপনি এই ধারণাটি প্রসারিত করতে পারেন:

def sanitised_input(prompt, type_=None, min_=None, max_=None, range_=None):
    if min_ is not None and max_ is not None and max_ < min_:
        raise ValueError("min_ must be less than or equal to max_.")
    while True:
        ui = input(prompt)
        if type_ is not None:
            try:
                ui = type_(ui)
            except ValueError:
                print("Input type must be {0}.".format(type_.__name__))
                continue
        if max_ is not None and ui > max_:
            print("Input must be less than or equal to {0}.".format(max_))
        elif min_ is not None and ui < min_:
            print("Input must be greater than or equal to {0}.".format(min_))
        elif range_ is not None and ui not in range_:
            if isinstance(range_, range):
                template = "Input must be between {0.start} and {0.stop}."
                print(template.format(range_))
            else:
                template = "Input must be {0}."
                if len(range_) == 1:
                    print(template.format(*range_))
                else:
                    expected = " or ".join((
                        ", ".join(str(x) for x in range_[:-1]),
                        str(range_[-1])
                    ))
                    print(template.format(expected))
        else:
            return ui

ব্যবহারের সাথে যেমন:

age = sanitised_input("Enter your age: ", int, 1, 101)
answer = sanitised_input("Enter your answer: ", str.lower, range_=('a', 'b', 'c', 'd'))

সাধারণ সমস্যা এবং কেন তাদের এড়ানো উচিত

অপ্রয়োজনীয় inputবিবৃতিগুলির অপ্রয়োজনীয় ব্যবহার

এই পদ্ধতিটি কার্যকর তবে সাধারণত দুর্বল শৈলী হিসাবে বিবেচিত:

data = input("Please enter a loud message (must be all caps): ")
while not data.isupper():
    print("Sorry, your response was not loud enough.")
    data = input("Please enter a loud message (must be all caps): ")

এটি প্রথমে আকর্ষণীয় দেখাতে পারে কারণ এটি while Trueপদ্ধতির চেয়ে খাটো , তবে এটি সফ্টওয়্যার বিকাশের নিজের পুনরাবৃত্তি করবেন না নীতি লঙ্ঘন করে । এটি আপনার সিস্টেমে বাগের সম্ভাবনা বাড়িয়ে তোলে। আপনি যদি পরিবর্তন inputকরে ২.7 এ ব্যাকপোর্ট করতে চান raw_inputতবে দুর্ঘটনাক্রমে কেবলমাত্র inputউপরের প্রথমটি পরিবর্তন করুন ? এটি SyntaxErrorঘটতে সবেমাত্র অপেক্ষা।

পুনরাবৃত্তি আপনার স্ট্যাক উড়ে যাবে

আপনি যদি কেবল পুনরাবৃত্তি সম্পর্কে শিখেন তবে আপনি এটি ব্যবহার get_non_negative_intকরতে প্ররোচিত হতে পারেন যাতে আপনি যখন লুপটি নিষ্পত্তি করতে পারেন।

def get_non_negative_int(prompt):
    try:
        value = int(input(prompt))
    except ValueError:
        print("Sorry, I didn't understand that.")
        return get_non_negative_int(prompt)

    if value < 0:
        print("Sorry, your response must not be negative.")
        return get_non_negative_int(prompt)
    else:
        return value

এটি বেশিরভাগ সময় সূক্ষ্মভাবে কাজ করে বলে মনে হয় তবে ব্যবহারকারী যদি বেশিরভাগ সময় অবৈধ ডেটা প্রবেশ করে তবে স্ক্রিপ্টটি একটি দিয়ে শেষ হবে RuntimeError: maximum recursion depth exceeded। আপনি ভাবতে পারেন "কোনও বোকা পরপর 1000 টি ভুল করতে পারে না", তবে আপনি বোকা লোকদের কদর্যতা অবমূল্যায়ন করছেন!


53
অনেক মজার উদাহরণ সহ এটি পড়ার মজা ud আন্ডাররেটেড পাঠ: "বোকা লোকদের চাতুর্যকে মূল্যহীন করবেন না!"
ভিপিবানো

3
আমি যেভাবেই হোক প্রশ্নোত্তর উভয়কেই উত্সাহিত করেছি, তারা যেমন দুর্দান্ত, তবে আপনি "ডিকটি সিক্স" এর সাথে চুক্তিটি সিল করেছিলেন। ভাল হয়েছে, কেভিন।
ইরাকাল্পার

1
বোকা লোকদের দক্ষতা ... এবং চালাক আক্রমণকারীদের অনুমান করবেন না। এই ধরণের জিনিসটির জন্য একটি ডস আক্রমণ সবচেয়ে সহজ হবে, তবে অন্যরাও এটি হতে পারে।
সলোমন উকো

আমরা কি অপ্রয়োজনীয় ইনপুটগুলির পরিবর্তে নতুন "ওয়ালরাস" অপারেটরটি ব্যবহার করতে পারি? এটিও কি খুব খারাপ স্টাইল?
জে অরুণ মণি

1
@ জারুনমণি আমার মনে হয় না এটি খারাপ স্টাইল হবে তবে এটি সম্ভবত কিছুটা কম পঠনযোগ্য। আপনার কাছে inputপ্রতি
লুপটিতে

39

আপনি কেন while Trueএই লুপটি ভেঙে ফেলবেন এবং আপনি যখন নিজের বিবরণটি ঠিক তখনই বানাতে পারবেন তবে আপনার একবার বয়স হওয়ার পরে যা চান তা সমস্ত বন্ধ করা উচিত?

age = None
while age is None:
    input_value = input("Please enter your age: ")
    try:
        # try and convert the string input to a number
        age = int(input_value)
    except ValueError:
        # tell the user off
        print("{input} is not a number, please enter a number only".format(input=input_value))
if age >= 18:
    print("You are able to vote in the United States!")
else:
    print("You are not able to vote in the United States.")

এটি নিম্নলিখিত ফলাফল হতে পারে:

Please enter your age: *potato*
potato is not a number, please enter a number only
Please enter your age: *5*
You are not able to vote in the United States.

এটি কার্যকর হবে যেহেতু বয়সের কোনও মান কখনই আসবে না এবং কোডটি আপনার "ব্যবসায়িক প্রক্রিয়া" এর যুক্তি অনুসরণ করে


22

যদিও গৃহীত উত্তরটি আশ্চর্যজনক। আমি এই সমস্যার জন্য একটি দ্রুত হ্যাক ভাগ করতে চাই। (এটি নেতিবাচক বয়সের সমস্যারও যত্ন নেয়))

f=lambda age: (age.isdigit() and ((int(age)>=18  and "Can vote" ) or "Cannot vote")) or \
f(input("invalid input. Try again\nPlease enter your age: "))
print(f(input("Please enter your age: ")))

PS এই কোডটি অজগর 3.x এর জন্য is


1
মনে রাখবেন যে এই কোডটি পুনরাবৃত্তিযোগ্য তবে এখানে পুনরাবৃত্তি প্রয়োজনীয় নয়, এবং কেভিন বলেছেন যে এটি আপনার স্ট্যাকটি ফুটিয়ে তুলতে পারে।
প্রধানমন্ত্রী 2 রিং

2
@ পিএম 2 রিং - আপনি ঠিক বলেছেন। তবে এখানে আমার উদ্দেশ্যটি ছিল কেবল "শর্ট সার্কিট" কীভাবে কোডের দীর্ঘ টুকরোকে ছোট করে (শোভিত করতে পারে) তা দেখানো to
aaveg

11
আপনি কেন একটি ভেরিয়েবলকে ল্যাম্বডা বরাদ্দ করবেন, কেবল defপরিবর্তে ব্যবহার করুন। def f(age):চেয়ে অনেক পরিস্কার হয়f = lambda age:
GP89

3
কিছু ক্ষেত্রে, আপনার একবার বয়স প্রয়োজন হতে পারে এবং তারপরে সেই ফাংশনটির কোনও ব্যবহার নেই। কেউ কাজ শেষ করার পরে কোনও ফাংশন ব্যবহার করতে এবং এটিকে ফেলে দিতে চায়। এছাড়াও, এটি সর্বোত্তম উপায় নাও হতে পারে তবে এটি অবশ্যই করার একটি ভিন্ন উপায় (যা আমার সমাধানের উদ্দেশ্য ছিল)।
aaveg

@ অ্যাভেগ আপনি কীভাবে এই কোডটি ব্যবহারকারীর দ্বারা সরবরাহিত বয়স বাঁচানোর জন্য চালু করবেন?
অত্যাচারী রেকুবানস

12

সুতরাং, আমি সম্প্রতি এর সাথে অনুরূপ কিছু নিয়ে গণ্ডগোল করছি, এবং আমি নিম্নলিখিত সমাধানটি নিয়ে এসেছি, যা কোনও ইনজিকাল উপায়ে যাচাই করার আগে ইনপুট পাওয়ার কোনও উপায় ব্যবহার করে যা জাঙ্কটিকে প্রত্যাখ্যান করে।

read_single_keypress()সৌজন্য https://stackoverflow.com/a/6599441/4532996

def read_single_keypress() -> str:
    """Waits for a single keypress on stdin.
    -- from :: https://stackoverflow.com/a/6599441/4532996
    """

    import termios, fcntl, sys, os
    fd = sys.stdin.fileno()
    # save old state
    flags_save = fcntl.fcntl(fd, fcntl.F_GETFL)
    attrs_save = termios.tcgetattr(fd)
    # make raw - the way to do this comes from the termios(3) man page.
    attrs = list(attrs_save) # copy the stored version to update
    # iflag
    attrs[0] &= ~(termios.IGNBRK | termios.BRKINT | termios.PARMRK
                  | termios.ISTRIP | termios.INLCR | termios. IGNCR
                  | termios.ICRNL | termios.IXON )
    # oflag
    attrs[1] &= ~termios.OPOST
    # cflag
    attrs[2] &= ~(termios.CSIZE | termios. PARENB)
    attrs[2] |= termios.CS8
    # lflag
    attrs[3] &= ~(termios.ECHONL | termios.ECHO | termios.ICANON
                  | termios.ISIG | termios.IEXTEN)
    termios.tcsetattr(fd, termios.TCSANOW, attrs)
    # turn off non-blocking
    fcntl.fcntl(fd, fcntl.F_SETFL, flags_save & ~os.O_NONBLOCK)
    # read a single keystroke
    try:
        ret = sys.stdin.read(1) # returns a single character
    except KeyboardInterrupt:
        ret = 0
    finally:
        # restore old state
        termios.tcsetattr(fd, termios.TCSAFLUSH, attrs_save)
        fcntl.fcntl(fd, fcntl.F_SETFL, flags_save)
    return ret

def until_not_multi(chars) -> str:
    """read stdin until !(chars)"""
    import sys
    chars = list(chars)
    y = ""
    sys.stdout.flush()
    while True:
        i = read_single_keypress()
        _ = sys.stdout.write(i)
        sys.stdout.flush()
        if i not in chars:
            break
        y += i
    return y

def _can_you_vote() -> str:
    """a practical example:
    test if a user can vote based purely on keypresses"""
    print("can you vote? age : ", end="")
    x = int("0" + until_not_multi("0123456789"))
    if not x:
        print("\nsorry, age can only consist of digits.")
        return
    print("your age is", x, "\nYou can vote!" if x >= 18 else "Sorry! you can't vote")

_can_you_vote()

আপনি এখানে সম্পূর্ণ মডিউলটি খুঁজে পেতে পারেন ।

উদাহরণ:

$ ./input_constrain.py
can you vote? age : a
sorry, age can only consist of digits.
$ ./input_constrain.py 
can you vote? age : 23<RETURN>
your age is 23
You can vote!
$ _

দ্রষ্টব্য যে এই বাস্তবায়নের প্রকৃতি হ'ল এটি কোনও অঙ্ক নয় এমন কিছু পড়ার সাথে সাথে স্টিডিনটি বন্ধ করে দেয়। আমি প্রবেশের পরে আঘাত করিনি a, তবে আমার সংখ্যাগুলি পরে দরকার ছিল।

আপনি thismany()এটি একই মডিউলে ফাংশনের সাথে একত্রীকরণ করতে পারেন কেবল তিন অঙ্কের অনুমতি দেওয়ার জন্য।


12

কার্যকরী পন্থা বা " দেখি মা কোনও লুপ নেই! ":

from itertools import chain, repeat

prompts = chain(["Enter a number: "], repeat("Not a number! Try again: "))
replies = map(input, prompts)
valid_response = next(filter(str.isdigit, replies))
print(valid_response)
Enter a number:  a
Not a number! Try again:  b
Not a number! Try again:  1
1

অথবা আপনি যদি অন্য উত্তরের মতো একটি ইনপুট প্রম্পট থেকে "খারাপ ইনপুট" বার্তা আলাদা করতে চান:

prompt_msg = "Enter a number: "
bad_input_msg = "Sorry, I didn't understand that."
prompts = chain([prompt_msg], repeat('\n'.join([bad_input_msg, prompt_msg])))
replies = map(input, prompts)
valid_response = next(filter(str.isdigit, replies))
print(valid_response)
Enter a number:  a
Sorry, I didn't understand that.
Enter a number:  b
Sorry, I didn't understand that.
Enter a number:  1
1

এটা কিভাবে কাজ করে?

  1. prompts = chain(["Enter a number: "], repeat("Not a number! Try again: "))
    এই সমন্বয় itertools.chainএবং itertools.repeatকোনো ইটারেটরে যা স্ট্রিং সমর্পণ করা হবে তৈরি করবে "Enter a number: "একবার, এবং "Not a number! Try again: "সময়ের অসীম সংখ্যা:
    for prompt in prompts:
        print(prompt)
    Enter a number: 
    Not a number! Try again: 
    Not a number! Try again: 
    Not a number! Try again: 
    # ... and so on
  2. replies = map(input, prompts)- এখানে ফাংশনে পূর্ববর্তী পদক্ষেপ থেকে mapসমস্ত promptsস্ট্রিং প্রয়োগ করা হবে input। উদাহরণ:
    for reply in replies:
        print(reply)
    Enter a number:  a
    a
    Not a number! Try again:  1
    1
    Not a number! Try again:  it doesn't care now
    it doesn't care now
    # and so on...
  3. আমরা কেবল সেই সংখ্যাগুলিতে থাকা স্ট্রিংগুলি ফিল্টার করতে filterএবং ব্যবহার str.isdigitকরতে পারি:
    only_digits = filter(str.isdigit, replies)
    for reply in only_digits:
        print(reply)
    Enter a number:  a
    Not a number! Try again:  1
    1
    Not a number! Try again:  2
    2
    Not a number! Try again:  b
    Not a number! Try again: # and so on...
    এবং আমরা ব্যবহার করি কেবলমাত্র প্রথম সংখ্যাগুলির জন্য কেবল স্ট্রিং next

অন্যান্য বৈধতা বিধি:

  1. স্ট্রিং পদ্ধতি: অবশ্যই আপনি অন্যান্য স্ট্রিং পদ্ধতি ব্যবহার করতে পারেন str.isalphaকেবলমাত্র বর্ণানুক্রমিক স্ট্রিং str.isupperপেতে , বা কেবল বড় হাতের অক্ষর পেতে। সম্পূর্ণ তালিকার জন্য ডক্স দেখুন ।

  2. সদস্যতা পরীক্ষা:
    এটি সম্পাদন করার বিভিন্ন উপায় রয়েছে। এর মধ্যে একটি __contains__পদ্ধতি ব্যবহার করে :

    from itertools import chain, repeat
    
    fruits = {'apple', 'orange', 'peach'}
    prompts = chain(["Enter a fruit: "], repeat("I don't know this one! Try again: "))
    replies = map(input, prompts)
    valid_response = next(filter(fruits.__contains__, replies))
    print(valid_response)
    Enter a fruit:  1
    I don't know this one! Try again:  foo
    I don't know this one! Try again:  apple
    apple
  3. সংখ্যা তুলনা:
    দরকারী তুলনা পদ্ধতি আছে যা আমরা এখানে ব্যবহার করতে পারি। উদাহরণস্বরূপ, __lt__( <) এর জন্য:

    from itertools import chain, repeat
    
    prompts = chain(["Enter a positive number:"], repeat("I need a positive number! Try again:"))
    replies = map(input, prompts)
    numeric_strings = filter(str.isnumeric, replies)
    numbers = map(float, numeric_strings)
    is_positive = (0.).__lt__
    valid_response = next(filter(is_positive, numbers))
    print(valid_response)
    Enter a positive number: a
    I need a positive number! Try again: -5
    I need a positive number! Try again: 0
    I need a positive number! Try again: 5
    5.0

    অথবা, যদি আপনি ডান্ডার পদ্ধতিগুলি ব্যবহার করতে পছন্দ করেন না (ডান্ডার = ডাবল-আন্ডারস্কোর), আপনি সর্বদা আপনার নিজের ফাংশনটি সংজ্ঞায়িত করতে পারেন, বা operatorমডিউলটি ব্যবহার করতে পারেন ।

  4. পথের অস্তিত্ব:
    এখানে একটি pathlibগ্রন্থাগার এবং এর Path.existsপদ্ধতি ব্যবহার করতে পারে :

    from itertools import chain, repeat
    from pathlib import Path
    
    prompts = chain(["Enter a path: "], repeat("This path doesn't exist! Try again: "))
    replies = map(input, prompts)
    paths = map(Path, replies)
    valid_response = next(filter(Path.exists, paths))
    print(valid_response)
    Enter a path:  a b c
    This path doesn't exist! Try again:  1
    This path doesn't exist! Try again:  existing_file.txt
    existing_file.txt

সীমাবদ্ধ প্রচেষ্টা:

আপনি যদি কোনও ব্যবহারকারীকে অসীম সংখ্যক বার জিজ্ঞাসা করে অত্যাচার করতে না চান তবে আপনি কলটিতে একটি সীমা নির্দিষ্ট করতে পারেন itertools.repeat। এটি nextফাংশনটির একটি ডিফল্ট মান প্রদানের সাথে একত্রিত হতে পারে :

from itertools import chain, repeat

prompts = chain(["Enter a number:"], repeat("Not a number! Try again:", 2))
replies = map(input, prompts)
valid_response = next(filter(str.isdigit, replies), None)
print("You've failed miserably!" if valid_response is None else 'Well done!')
Enter a number: a
Not a number! Try again: b
Not a number! Try again: c
You've failed miserably!

পূর্ববর্তী ইনপুট ডেটা:

কখনও কখনও আমরা কোনও ইনপুট প্রত্যাখ্যান করতে চাই না যদি ব্যবহারকারী দুর্ঘটনাক্রমে এটি ক্যাপগুলিতে সরবরাহ করে বা স্ট্রিংটির শুরুতে বা শেষের সাথে কোনও স্থান সরবরাহ করে । এই সাধারণ ভুলগুলি অ্যাকাউন্টে নেওয়ার জন্য আমরা প্রয়োগ করে str.lowerএবং ইনপুট ডেটা প্রিপ্রসেস করতে পারিstr.strip পদ্ধতিগুলির । উদাহরণস্বরূপ, সদস্যপদের ক্ষেত্রে পরীক্ষার কোডটি দেখতে এরকম হবে:

from itertools import chain, repeat

fruits = {'apple', 'orange', 'peach'}
prompts = chain(["Enter a fruit: "], repeat("I don't know this one! Try again: "))
replies = map(input, prompts)
lowercased_replies = map(str.lower, replies)
stripped_replies = map(str.strip, lowercased_replies)
valid_response = next(filter(fruits.__contains__, stripped_replies))
print(valid_response)
Enter a fruit:  duck
I don't know this one! Try again:     Orange
orange

ক্ষেত্রে যখন আপনার প্রিপ্রোসেসিংয়ের জন্য অনেকগুলি ফাংশন ব্যবহার করা থাকে তখন কোনও ফাংশন রচনা সম্পাদন করে কোনও ফাংশন ব্যবহার করা সহজ । উদাহরণস্বরূপ, এখান থেকে একটি ব্যবহার করে :

from itertools import chain, repeat

from lz.functional import compose

fruits = {'apple', 'orange', 'peach'}
prompts = chain(["Enter a fruit: "], repeat("I don't know this one! Try again: "))
replies = map(input, prompts)
process = compose(str.strip, str.lower)  # you can add more functions here
processed_replies = map(process, replies)
valid_response = next(filter(fruits.__contains__, processed_replies))
print(valid_response)
Enter a fruit:  potato
I don't know this one! Try again:   PEACH
peach

বৈধতা নিয়মের সংমিশ্রণ:

একটি সাধারণ ক্ষেত্রে, উদাহরণস্বরূপ, যখন প্রোগ্রামটি 1 থেকে 120 এর মধ্যে বয়সের জন্য জিজ্ঞাসা করে, একজন কেবল অন্যটিকে যুক্ত করতে পারে filter :

from itertools import chain, repeat

prompt_msg = "Enter your age (1-120): "
bad_input_msg = "Wrong input."
prompts = chain([prompt_msg], repeat('\n'.join([bad_input_msg, prompt_msg])))
replies = map(input, prompts)
numeric_replies = filter(str.isdigit, replies)
ages = map(int, numeric_replies)
positive_ages = filter((0).__lt__, ages)
not_too_big_ages = filter((120).__ge__, positive_ages)
valid_response = next(not_too_big_ages)
print(valid_response)

কিন্তু যখন অনেকগুলি বিধি থাকে তখন লজিকাল সংমিশ্রণ সম্পাদন করে কোনও ফাংশন প্রয়োগ করা ভাল । নিম্নলিখিত উদাহরণে আমি এখান থেকে প্রস্তুত একটি ব্যবহার করব :

from functools import partial
from itertools import chain, repeat

from lz.logical import conjoin


def is_one_letter(string: str) -> bool:
    return len(string) == 1


rules = [str.isalpha, str.isupper, is_one_letter, 'C'.__le__, 'P'.__ge__]

prompt_msg = "Enter a letter (C-P): "
bad_input_msg = "Wrong input."
prompts = chain([prompt_msg], repeat('\n'.join([bad_input_msg, prompt_msg])))
replies = map(input, prompts)
valid_response = next(filter(conjoin(*rules), replies))
print(valid_response)
Enter a letter (C-P):  5
Wrong input.
Enter a letter (C-P):  f
Wrong input.
Enter a letter (C-P):  CDE
Wrong input.
Enter a letter (C-P):  Q
Wrong input.
Enter a letter (C-P):  N
N

দুর্ভাগ্যক্রমে, যদি প্রতিটি ব্যর্থ মামলার জন্য কারও কাছে কাস্টম বার্তা প্রয়োজন হয় তবে আমি ভয় করি, এর থেকে সুন্দর কোনও কার্যকরী উপায় নেই। বা, কমপক্ষে, আমি একটিও পাইনি।


কি পুরো এবং দুর্দান্ত উত্তর, ব্যাখ্যা ব্রেকডাউন দুর্দান্ত ছিল।
লোকেন

আপনার শৈলীটি ব্যবহার করে, কেউ সদস্যপদ পরীক্ষার জন্য হোয়াইটস্পেস বাদ দিয়ে এবং ইনপুটটিকে লো-কেসিং সম্পর্কে কীভাবে যেতে পারে? আমি এমন একটি সেট তৈরি করতে চাই না যা অবশ্যই উপরের এবং ছোট উভয় উদাহরণকে অন্তর্ভুক্ত করবে। আমি হোয়াইটস্পেস ইনপুট ভুলগুলির জন্যও অনুমতি দিতে চাই।
অস্টিন

1
@ অস্টিন আমি প্রিপ্রোসেসিংয়ে একটি নতুন বিভাগ যুক্ত করেছি। এটা দেখ.
জর্জি

এটি আমাকে রিঅ্যাকটিভএক্সের কথা মনে করিয়ে দেয়। তবে সম্ভবত এটি প্রথম স্থানে ক্রিয়ামূলক ভাষা দ্বারা অনুপ্রাণিত হয়েছিল?
মতিন উলহাক

8

ক্লিক ব্যবহার করুন :

ক্লিক হ'ল কমান্ড-লাইন ইন্টারফেসের জন্য একটি লাইব্রেরি এবং এটি ব্যবহারকারীর কাছ থেকে বৈধ প্রতিক্রিয়া জিজ্ঞাসা করার জন্য কার্যকারিতা সরবরাহ করে।

সাধারণ উদাহরণ:

import click

number = click.prompt('Please enter a number', type=float)
print(number)
Please enter a number: 
 a
Error: a is not a valid floating point value
Please enter a number: 
 10
10.0

নোট করুন কীভাবে এটি স্ট্রিংয়ের মানটিকে স্বয়ংক্রিয়ভাবে একটি ফ্লোটে রূপান্তর করে।

মান একটি ব্যাপ্তির মধ্যে রয়েছে কিনা তা পরীক্ষা করা হচ্ছে:

বিভিন্ন কাস্টম প্রকার সরবরাহ করা আছে। একটি নির্দিষ্ট পরিসরে একটি নম্বর পেতে আমরা ব্যবহার করতে পারি IntRange:

age = click.prompt("What's your age?", type=click.IntRange(1, 120))
print(age)
What's your age?: 
 a
Error: a is not a valid integer
What's your age?: 
 0
Error: 0 is not in the valid range of 1 to 120.
What's your age?: 
 5
5

আমরা সীমাগুলির মধ্যে একটিরও নির্দিষ্ট করতে পারি minবা max:

age = click.prompt("What's your age?", type=click.IntRange(min=14))
print(age)
What's your age?: 
 0
Error: 0 is smaller than the minimum valid value 14.
What's your age?: 
 18
18

সদস্যতা পরীক্ষা:

click.Choiceপ্রকার ব্যবহার । ডিফল্টরূপে এই চেকটি কেস-সংবেদনশীল।

choices = {'apple', 'orange', 'peach'}
choice = click.prompt('Provide a fruit', type=click.Choice(choices, case_sensitive=False))
print(choice)
Provide a fruit (apple, peach, orange): 
 banana
Error: invalid choice: banana. (choose from apple, peach, orange)
Provide a fruit (apple, peach, orange): 
 OrAnGe
orange

পাথ এবং ফাইলগুলির সাথে কাজ করা:

একটি click.Pathপ্রকারের সাহায্যে আমরা বিদ্যমান পাথগুলি পরীক্ষা করতে এবং সেগুলি সমাধান করতে পারি:

path = click.prompt('Provide path', type=click.Path(exists=True, resolve_path=True))
print(path)
Provide path: 
 nonexistent
Error: Path "nonexistent" does not exist.
Provide path: 
 existing_folder
'/path/to/existing_folder

ফাইল পড়া এবং লেখার মাধ্যমে এটি করা যেতে পারে click.File:

file = click.prompt('In which file to write data?', type=click.File('w'))
with file.open():
    file.write('Hello!')
# More info about `lazy=True` at:
# https://click.palletsprojects.com/en/7.x/arguments/#file-opening-safety
file = click.prompt('Which file you wanna read?', type=click.File(lazy=True))
with file.open():
    print(file.read())
In which file to write data?: 
         # <-- provided an empty string, which is an illegal name for a file
In which file to write data?: 
 some_file.txt
Which file you wanna read?: 
 nonexistent.txt
Error: Could not open file: nonexistent.txt: No such file or directory
Which file you wanna read?: 
 some_file.txt
Hello!

অন্যান্য উদাহরণ:

পাসওয়ার্ড নিশ্চিতকরণ:

password = click.prompt('Enter password', hide_input=True, confirmation_prompt=True)
print(password)
Enter password: 
 ······
Repeat for confirmation: 
 ·
Error: the two entered values do not match
Enter password: 
 ······
Repeat for confirmation: 
 ······
qwerty

ডিফল্ট মান:

এই ক্ষেত্রে, Enterকোনও মান প্রবেশ না করে কেবল (বা আপনি যে কী ব্যবহার করুন) টিপলে আপনাকে একটি ডিফল্ট দেওয়া হবে:

number = click.prompt('Please enter a number', type=int, default=42)
print(number)
Please enter a number [42]: 
 a
Error: a is not a valid integer
Please enter a number [42]: 

42

3
def validate_age(age):
    if age >=0 :
        return True
    return False

while True:
    try:
        age = int(raw_input("Please enter your age:"))
        if validate_age(age): break
    except ValueError:
        print "Error: Invalid age."

2

ড্যানিয়েল কি এবং প্যাট্রিক আর্টনারের দুর্দান্ত পরামর্শগুলির উপর ভিত্তি করে এখানে একটি আরও সাধারণ সমাধান দেওয়া হয়েছে।

# Assuming Python3
import sys

class ValidationError(ValueError):  # thanks Patrick Artner
    pass

def validate_input(prompt, cast=str, cond=(lambda x: True), onerror=None):
    if onerror==None: onerror = {}
    while True:
        try:
            data = cast(input(prompt))
            if not cond(data): raise ValidationError
            return data
        except tuple(onerror.keys()) as e:  # thanks Daniel Q
            print(onerror[type(e)], file=sys.stderr)

আমি এর পরিবর্তে স্পষ্ট ifএবং raiseবিবৃতি বেছে নিয়েছি assert, কারণ দৃ checking়তা পরীক্ষা করা বন্ধ হতে পারে, অন্যদিকে দৃ valid়তা দেওয়ার জন্য বৈধতা সর্বদা চালু থাকা উচিত।

এটি বিভিন্ন বৈধতা শর্ত সহ বিভিন্ন ধরণের ইনপুট পেতে ব্যবহৃত হতে পারে। উদাহরণ স্বরূপ:

# No validation, equivalent to simple input:
anystr = validate_input("Enter any string: ")

# Get a string containing only letters:
letters = validate_input("Enter letters: ",
    cond=str.isalpha,
    onerror={ValidationError: "Only letters, please!"})

# Get a float in [0, 100]:
percentage = validate_input("Percentage? ",
    cast=float, cond=lambda x: 0.0<=x<=100.0,
    onerror={ValidationError: "Must be between 0 and 100!",
             ValueError: "Not a number!"})

অথবা, মূল প্রশ্নের উত্তর দিতে:

age = validate_input("Please enter your age: ",
        cast=int, cond=lambda a:0<=a<150,
        onerror={ValidationError: "Enter a plausible age, please!",
                 ValueError: "Enter an integer, please!"})
if age >= 18: 
    print("You are able to vote in the United States!")
else:
    print("You are not able to vote in the United States.")

1

আর একবার চেষ্টা কর:-

def takeInput(required):
  print 'ooo or OOO to exit'
  ans = raw_input('Enter: ')

  if not ans:
      print "You entered nothing...!"
      return takeInput(required) 

      ##  FOR Exit  ## 
  elif ans in ['ooo', 'OOO']:
    print "Closing instance."
    exit()

  else:
    if ans.isdigit():
      current = 'int'
    elif set('[~!@#$%^&*()_+{}":/\']+$').intersection(ans):
      current = 'other'
    elif isinstance(ans,basestring):
      current = 'str'        
    else:
      current = 'none'

  if required == current :
    return ans
  else:
    return takeInput(required)

## pass the value in which type you want [str/int/special character(as other )]
print "input: ", takeInput('str')

0

যখন কোনও try/ exceptব্লক কাজ করবে, এই কাজটি সম্পাদন করার জন্য একটি আরও দ্রুত এবং পরিষ্কার উপায় ব্যবহার করা হবে str.isdigit()

while True:
    age = input("Please enter your age: ")
    if age.isdigit():
        age = int(age)
        break
    else:
        print("Invalid number '{age}'. Try again.".format(age=age))

if age >= 18: 
    print("You are able to vote in the United States!")
else:
    print("You are not able to vote in the United States.")

0

ভাল প্রশ্ন! আপনি এই জন্য নিম্নলিখিত কোড চেষ্টা করতে পারেন। =)

এই কোডটি ইনপুট ( ) এর ডেটা ধরণের সন্ধান করতে ast.literal_eval () ব্যবহার করে । তারপরে এটি নিম্নলিখিত অ্যালগরিদম অনুসরণ করে:age

  1. ব্যবহারকারীকে তার / তার ইনপুট করতে বলুন age

    1.1। যদি ageহয় floatবা intডেটা টাইপ:

    • যদি পরীক্ষা করে দেখুন age>=18। যদি age>=18, উপযুক্ত আউটপুট মুদ্রণ করুন এবং প্রস্থান করুন।

    • যদি পরীক্ষা করে দেখুন 0<age<18। যদি 0<age<18, উপযুক্ত আউটপুট মুদ্রণ করুন এবং প্রস্থান করুন।

    • যদি age<=0, ব্যবহারকারীকে আবার বয়সের জন্য একটি বৈধ সংখ্যা ইনপুট করতে বলুন, ( উদাহরণস্বরূপ পদক্ষেপ 1 এ ফিরে যান)

    1.2। যদি ageনা হয় floatবা intডেটা টাইপ করা হয়, তবে ব্যবহারকারীকে তার / তার বয়স আবার ইনপুট করতে বলুন ( অর্থাত্ 1 ধাপে ফিরে যান)

কোডটি এখানে।

from ast import literal_eval

''' This function is used to identify the data type of input data.'''
def input_type(input_data):
    try:
        return type(literal_eval(input_data))
    except (ValueError, SyntaxError):
        return str

flag = True

while(flag):
    age = raw_input("Please enter your age: ")

    if input_type(age)==float or input_type(age)==int:
        if eval(age)>=18: 
            print("You are able to vote in the United States!") 
            flag = False 
        elif eval(age)>0 and eval(age)<18: 
            print("You are not able to vote in the United States.") 
            flag = False
        else: print("Please enter a valid number as your age.")

    else: print("Sorry, I didn't understand that.") 

0

আপনি সর্বদা সরল যদি-অন্য যুক্তি প্রয়োগ করতে পারেন এবং লুপের ifসাথে আপনার কোডে আরও একটি যুক্তি যুক্ত করতে পারেন for

while True:
     age = int(input("Please enter your age: "))
     if (age >= 18)  : 
         print("You are able to vote in the United States!")
     if (age < 18) & (age > 0):
         print("You are not able to vote in the United States.")
     else:
         print("Wrong characters, the input must be numeric")
         continue

এটি একটি অসীম লু হবে এবং আপনাকে অনির্দিষ্টকালের জন্য যুগে প্রবেশ করতে বলা হবে।


এটি আসলে প্রশ্নের উত্তর দেয় না। প্রশ্নটি ছিল একটি ব্যবহারকারী ইনপুট পাওয়ার বিষয়ে অনির্দিষ্টকালের জন্য নয়, কোনও বৈধ প্রতিক্রিয়া না দেওয়া পর্যন্ত
জর্জি

-1

ব্যবহারকারীর কেবলমাত্র নির্দিষ্ট সংখ্যকবার প্রবেশের অনুমতি দেওয়ার জন্য আপনি আরও সাধারণ যুক্তি লিখতে পারেন, যেমনটি অনেক বাস্তব-বিশ্বের অ্যাপ্লিকেশনগুলিতে একই ব্যবহার-কেস দেখা দেয়।

def getValidInt(iMaxAttemps = None):
  iCount = 0
  while True:
    # exit when maximum attempt limit has expired
    if iCount != None and iCount > iMaxAttemps:
       return 0     # return as default value

    i = raw_input("Enter no")
    try:
       i = int(i)
    except ValueError as e:
       print "Enter valid int value"
    else:
       break

    return i

age = getValidInt()
# do whatever you want to do.

1
আপনি প্রতিটি লুপের পরে আইকাউন্টের মান বাড়াতে ভুলে গেছেন
-থু ভুং

-1

আপনি সত্যিকারের লুপটি ইনপুট বিবৃতিটি কিছুক্ষণ তৈরি করতে পারেন তাই এটি বারবার ব্যবহারকারীদের ইনপুট চেয়েছে এবং তারপরে যদি ব্যবহারকারী আপনার পছন্দমতো প্রতিক্রিয়া প্রবেশ করে তবে সেই লুপটি ভেঙে ফেলুন। এবং আপনি অবৈধ প্রতিক্রিয়াগুলি পরিচালনা করতে ব্লক ব্যতীত চেষ্টা করে ও ব্যবহার করতে পারেন।

while True:

    var = True

    try:
        age = int(input("Please enter your age: "))

    except ValueError:
        print("Invalid input.")
        var = False

    if var == True:
        if age >= 18:
                print("You are able to vote in the United States.")
                break
        else:
            print("You are not able to vote in the United States.")

ভেরিয়েবলটি কেবলমাত্র তাই যাতে ব্যবহারকারী কোনও পূর্ণসংখ্যার পরিবর্তে কোনও স্ট্রিং প্রবেশ করে তবে প্রোগ্রামটি ফিরে আসবে না "আপনি যুক্তরাষ্ট্রে ভোট দিতে পারবেন না।"


-1

ব্যবহারকারীর সত্যিকারের মান প্রবেশ না করা পর্যন্ত "সময়" বিবৃতিটি ব্যবহার করুন এবং যদি ইনপুট মানটি কোনও সংখ্যা না হয় বা এটি একটি নাল মান এড়িয়ে যায় এবং আবার জিজ্ঞাসা করার চেষ্টা করুন ইত্যাদি। উদাহরণস্বরূপ আমি আপনার প্রশ্নের উত্তর দেওয়ার চেষ্টা করেছি। যদি আমরা ধরে নিই যে আমাদের বয়স 1 থেকে 150 এর মধ্যে হয় তবে ইনপুট মান গৃহীত হয়, অন্যথায় এটি একটি ভুল মান। প্রোগ্রামটি সমাপ্ত করার জন্য, ব্যবহারকারী 0 টি কী ব্যবহার করতে পারেন এবং মান হিসাবে এটি প্রবেশ করতে পারেন।

দ্রষ্টব্য: কোডের উপরে মন্তব্যগুলি পড়ুন।

# If your input value is only a number then use "Value.isdigit() == False".
# If you need an input that is a text, you should remove "Value.isdigit() == False".
def Input(Message):
    Value = None
    while Value == None or Value.isdigit() == False:
        try:        
            Value = str(input(Message)).strip()
        except InputError:
            Value = None
    return Value

# Example:
age = 0
# If we suppose that our age is between 1 and 150 then input value accepted,
# else it's a wrong value.
while age <=0 or age >150:
    age = int(Input("Please enter your age: "))
    # For terminating program, the user can use 0 key and enter it as an a value.
    if age == 0:
        print("Terminating ...")
        exit(0)

if age >= 18 and age <=150: 
    print("You are able to vote in the United States!")
else:
    print("You are not able to vote in the United States.")

-1

একটি অনুকূলিতকরণ ValidationErrorএবং পূর্ণসংখ্যা ইনপুটগুলির জন্য ((চ্ছিক) ব্যাপ্তির বৈধতা ব্যবহার করে ইনপুট বৈধতা ব্যবহার করার জন্য আরও একটি সমাধান :

class ValidationError(ValueError): 
    """Special validation error - its message is supposed to be printed"""
    pass

def RangeValidator(text,num,r):
    """Generic validator - raises 'text' as ValidationError if 'num' not in range 'r'."""
    if num in r:
        return num
    raise ValidationError(text)

def ValidCol(c): 
    """Specialized column validator providing text and range."""
    return RangeValidator("Columns must be in the range of 0 to 3 (inclusive)", 
                          c, range(4))

def ValidRow(r): 
    """Specialized row validator providing text and range."""
    return RangeValidator("Rows must be in the range of 5 to 15(exclusive)",
                          r, range(5,15))

ব্যবহার:

def GetInt(text, validator=None):
    """Aks user for integer input until a valid integer is given. If provided, 
    a 'validator' function takes the integer and either raises a 
    ValidationError to be printed or returns the valid number. 
    Non integers display a simple error message."""
    print()
    while True:
        n = input(text)
        try:
            n = int(n)

            return n if validator is None else validator(n)

        except ValueError as ve:
            # prints ValidationErrors directly - else generic message:
            if isinstance(ve, ValidationError):
                print(ve)
            else:
                print("Invalid input: ", n)


column = GetInt("Pleased enter column: ", ValidCol)
row = GetInt("Pleased enter row: ", ValidRow)
print( row, column)

আউটপুট:

Pleased enter column: 22
Columns must be in the range of 0 to 3 (inclusive)
Pleased enter column: -2
Columns must be in the range of 0 to 3 (inclusive)
Pleased enter column: 2
Pleased enter row: a
Invalid input:  a
Pleased enter row: 72
Rows must be in the range of 5 to 15(exclusive)
Pleased enter row: 9  

9, 2

-1

এখানে একটি ক্লিনার, আরও সাধারণ সমাধান রয়েছে যা / অন্যগুলি ব্লক করে থাকলে পুনরাবৃত্তিকে এড়িয়ে চলে: একটি অভিধানে (ত্রুটি, ত্রুটি প্রম্পট) জোড়া লাগে এমন একটি ফাংশন লিখুন এবং আপনার সমস্ত মান-যাচাই বাছাইয়ের সাথে কর do

def validate_input(prompt, error_map):
    while True:
        try:
            data = int(input(prompt))
            # Insert your non-exception-throwing conditionals here
            assert data > 0
            return data
        # Print whatever text you want the user to see
        # depending on how they messed up
        except tuple(error_map.keys()) as e:
            print(error_map[type(e)])

ব্যবহার:

d = {ValueError: 'Integers only', AssertionError: 'Positive numbers only', 
     KeyboardInterrupt: 'You can never leave'}
user_input = validate_input("Positive number: ", d)

-1

পুনরাবৃত্তি ফাংশন ব্যবহার করে অবিচ্ছিন্ন ব্যবহারকারী ইনপুট :

দড়ি

def askName():
    return input("Write your name: ").strip() or askName()

name = askName()

পূর্ণসংখ্যা

def askAge():
    try: return int(input("Enter your age: "))
    except ValueError: return askAge()

age = askAge()

এবং পরিশেষে, প্রশ্নের প্রয়োজনীয়তা:

def askAge():
    try: return int(input("Enter your age: "))
    except ValueError: return askAge()

age = askAge()

responseAge = [
    "You are able to vote in the United States!",
    "You are not able to vote in the United States.",
][int(age < 18)]

print(responseAge)

-2

এর সহজ সমাধানটি হ'ল:

while True:
    age = int(input("Please enter your age: "))

    if (age<=0) or (age>120):
        print('Sorry, I did not understand that.Please try again')
        continue
    else:

        if age>=18:
            print("You are able to vote in the United States!")
        else:
            print("You are not able to vote in the United States.")
        break

উপরের কোডের ব্যাখ্যা: একটি বৈধ বয়সের জন্য, এটি ইতিবাচক হওয়া উচিত এবং সাধারণ শারীরিক বয়সের চেয়ে বেশি হওয়া উচিত নয়, উদাহরণস্বরূপ বলুন সর্বোচ্চ বয়স 120 হয়।

তারপরে আমরা বয়সের জন্য ব্যবহারকারীকে জিজ্ঞাসা করতে পারি এবং যদি বয়সের ইনপুটটি নেতিবাচক বা 120 এর বেশি হয় তবে আমরা এটিকে অবৈধ ইনপুট বিবেচনা করি এবং ব্যবহারকারীকে আবার চেষ্টা করতে বলি।

বৈধ ইনপুট প্রবেশ করানোর পরে, আমরা বয়স> = 18 বা তার বিপরীতে কিনা তা পরীক্ষা করে (নেস্টেড if-অন্য বিবৃতি ব্যবহার করে) সম্পাদন করি এবং ব্যবহারকারী ভোটদানের জন্য যোগ্য কিনা কোনও বার্তা মুদ্রণ করি


"দয়া করে আপনার বয়স লিখুন: ছদ্মবেশী ছয়" ": প্রশ্নে বর্ণিত একই ক্র্যাশ ...
বিডিএল

-2

স্ট্রিং হিসাবে ইনপুট নিন এবং ইনপুট চেক করতে আইডিডিজিট () ব্যবহার করুন কেবল অঙ্ক রয়েছে, খালি নয়, পোষাক হতে পারে না

while(True):
   #take input as string
   name = input('Enter age : ')
   #check if valid age, only digits
   print( name.isdigit() ) 

run output : 
Enter age : 12
True
Enter age : 
False
Enter age : qwd
False
Enter age : dw3
False
Enter age : 21de
False
Enter age : 1
True
Enter age : -1
False


এটি প্রশ্নের উত্তর দেয় না।
জর্জি
আমাদের সাইট ব্যবহার করে, আপনি স্বীকার করেছেন যে আপনি আমাদের কুকি নীতি এবং গোপনীয়তা নীতিটি পড়েছেন এবং বুঝতে পেরেছেন ।
Licensed under cc by-sa 3.0 with attribution required.